@@ -426,38 +426,35 @@ class FileUtil {
426
426
}
427
427
428
428
WindowsVersion checkWindowsVersion () {
429
+ WindowsVersion tmp = WindowsVersion .portable;
430
+
429
431
final key = calloc <IntPtr >();
432
+ final installPathPtr = calloc <Uint16 >(260 );
433
+ final dataSize = calloc <Uint32 >();
434
+ dataSize.value = 260 * 2 ;
435
+
430
436
final result = RegOpenKeyEx (HKEY_LOCAL_MACHINE , TEXT (windowsKeyPath), 0 ,
431
437
REG_SAM_FLAGS .KEY_READ , key);
432
438
if (result == WIN32_ERROR .ERROR_SUCCESS ) {
439
+ final queryResult = RegQueryValueEx (key.value, TEXT ('InstallPath' ),
440
+ nullptr, nullptr, installPathPtr.cast (), dataSize);
433
441
434
- WindowsVersion tmp = WindowsVersion .installed;
435
-
436
- // final installPathPtr = calloc<Uint16>(260);
437
- // final dataSize = calloc<Uint32>();
438
- // dataSize.value = 260 * 2;
439
- // final queryResult = RegQueryValueEx(key.value, TEXT('InstallPath'),
440
- // nullptr, nullptr, installPathPtr.cast(), dataSize);
441
- // if (queryResult == WIN32_ERROR.ERROR_SUCCESS) {
442
- // final currentPath = Platform.resolvedExecutable;
443
- // final installPath = installPathPtr.toDartString();
444
- // print("currentPath: $currentPath installPath: $installPath");
445
- // tmp = installPath == currentPath
446
- // ? WindowsVersion.installed
447
- // : WindowsVersion.portable;
448
- // } else {
449
- // tmp = WindowsVersion.portable;
450
- // }
451
-
452
- RegCloseKey (key.value);
453
- calloc.free (key);
454
- // calloc.free(installPathPtr);
455
- // calloc.free(dataSize);
456
- return tmp;
457
- } else {
458
- calloc.free (key);
459
- return WindowsVersion .portable;
442
+ if (queryResult == WIN32_ERROR .ERROR_SUCCESS ) {
443
+ final currentPath = Platform .resolvedExecutable;
444
+ final installPath = installPathPtr.cast <Utf16 >().toDartString ();
445
+ ILogger .info ("Get install path: $installPath and current path: $currentPath " );
446
+ tmp = installPath == currentPath
447
+ ? WindowsVersion .installed
448
+ : WindowsVersion .portable;
449
+ } else {
450
+ tmp = WindowsVersion .portable;
451
+ }
460
452
}
453
+ RegCloseKey (key.value);
454
+ calloc.free (key);
455
+ calloc.free (installPathPtr);
456
+ calloc.free (dataSize);
457
+ return tmp;
461
458
}
462
459
463
460
static ReleaseAsset getWindowsAsset (String latestVersion, ReleaseItem item) {
0 commit comments