Mercurial > dwindows
comparison win/edge.cpp @ 2223:a81b9031412e
Win: Change to using EdgeUpdate registry key instead of BLBeacon.
The BLBeacon registry key does not seem to update the version immediately after
receiving an Edge update, only after actually running Edge. The EdgeUpdate key
seems to be updated immediately, so use that instead so our juntion doesn't
point to a missing directory.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 23 Dec 2020 23:29:17 +0000 |
parents | f1241b668611 |
children | d3974aa8ad64 |
comparison
equal
deleted
inserted
replaced
2222:f1241b668611 | 2223:a81b9031412e |
---|---|
382 EdgeBrowser *DW_EDGE = NULL; | 382 EdgeBrowser *DW_EDGE = NULL; |
383 | 383 |
384 extern "C" { | 384 extern "C" { |
385 // Create a junction to Edge Stable current version so we can load it... | 385 // Create a junction to Edge Stable current version so we can load it... |
386 // For now we are using CreateProcess() to execute the mklink command... | 386 // For now we are using CreateProcess() to execute the mklink command... |
387 // May switch to using C code to do it instead since this may only work | 387 // May switch to using C code but that seems to be overly complicated |
388 // on Windows 10, but that seems to be overly complicated | |
389 void _DWCreateJunction(LPWSTR source, LPWSTR target) | 388 void _DWCreateJunction(LPWSTR source, LPWSTR target) |
390 { | 389 { |
391 // Command line must be at least 2 MAX_PATHs and "cmd /c mklink /J "<path1>" "<path2>"" (22) and a NULL | 390 // Command line must be at least 2 MAX_PATHs and "cmd /c mklink /J "<path1>" "<path2>"" (22) and a NULL |
392 WCHAR cmdLine[(MAX_PATH*2)+23] = L"cmd /c mklink /J \""; | 391 WCHAR cmdLine[(MAX_PATH*2)+23] = L"cmd /c mklink /J \""; |
393 STARTUPINFO si = {sizeof(si)}; | 392 STARTUPINFO si = {sizeof(si)}; |
394 PROCESS_INFORMATION pi = {0}; | 393 PROCESS_INFORMATION pi = {0}; |
394 | |
395 // Safety check | |
396 if(!source[0] || !target[0]) | |
397 return; | |
395 | 398 |
396 // Combine the command line components | 399 // Combine the command line components |
397 wcscat(cmdLine, target); | 400 wcscat(cmdLine, target); |
398 wcscat(cmdLine, L"\" \""); | 401 wcscat(cmdLine, L"\" \""); |
399 wcscat(cmdLine, source); | 402 wcscat(cmdLine, source); |
402 // First remove any existing junction to an old version | 405 // First remove any existing junction to an old version |
403 RemoveDirectoryW(target); | 406 RemoveDirectoryW(target); |
404 | 407 |
405 // Create the junction to the new version | 408 // Create the junction to the new version |
406 if(!CreateProcessW(NULL, cmdLine, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) | 409 if(!CreateProcessW(NULL, cmdLine, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) |
407 { | |
408 dw_debug("CreateProcess failed creating junction. GetLastError %d\n", GetLastError()); | |
409 return; | 410 return; |
410 } | |
411 | 411 |
412 // Wait until child process exits. | 412 // Wait until child process exits. |
413 WaitForSingleObject(pi.hProcess, INFINITE); | 413 WaitForSingleObject(pi.hProcess, INFINITE); |
414 | 414 |
415 // Close process and thread handles. | 415 // Close process and thread handles. |
425 DWORD dwBufferSize = sizeof(szBuffer); | 425 DWORD dwBufferSize = sizeof(szBuffer); |
426 static WCHAR EdgeStablePath[MAX_PATH+1] = {0}; | 426 static WCHAR EdgeStablePath[MAX_PATH+1] = {0}; |
427 | 427 |
428 /* If we haven't successfully gotten the path, try to find it in the registry */ | 428 /* If we haven't successfully gotten the path, try to find it in the registry */ |
429 if(!EdgeStablePath[0] && | 429 if(!EdgeStablePath[0] && |
430 RegOpenKeyExW(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Edge\\BLBeacon", 0, KEY_READ, &hKey) == ERROR_SUCCESS && | 430 RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\WOW6432Node\\Microsoft\\EdgeUpdate\\Clients\\{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}", 0, KEY_READ, &hKey) == ERROR_SUCCESS && |
431 RegQueryValueExW(hKey, L"version", 0, NULL, (LPBYTE)szBuffer, &dwBufferSize) == ERROR_SUCCESS) | 431 RegQueryValueExW(hKey, L"pv", 0, NULL, (LPBYTE)szBuffer, &dwBufferSize) == ERROR_SUCCESS) |
432 { | 432 { |
433 wcscpy(EdgeStablePath, L"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\"); | 433 wcscpy(EdgeStablePath, L"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\"); |
434 wcscat(EdgeStablePath, szBuffer); | 434 wcscat(EdgeStablePath, szBuffer); |
435 } | 435 } |
436 return EdgeStablePath; | 436 return EdgeStablePath; |