Skip to content

Commit 1133a8b

Browse files
committed
Support unicode encoded version info values
1 parent 6ed6b61 commit 1133a8b

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

packages/path_provider/path_provider_windows/lib/src/path_provider_windows_real.dart

+17-13
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,25 @@ class VersionInfoQuerier {
2525
if (versionInfo == null) {
2626
return null;
2727
}
28-
const String kEnUsLanguageCode = '040904e4';
29-
final Pointer<Utf16> keyPath =
30-
TEXT('\\StringFileInfo\\$kEnUsLanguageCode\\$key');
31-
final Pointer<Uint32> length = calloc<Uint32>();
32-
final Pointer<Pointer<Utf16>> valueAddress = calloc<Pointer<Utf16>>();
33-
try {
34-
if (VerQueryValue(versionInfo, keyPath, valueAddress, length) == 0) {
35-
return null;
28+
const List<String> languageCodes = <String>[
29+
'040904e4', // en-US, CP1252
30+
'040904b0', // en-US, Unicode
31+
];
32+
for (final String code in languageCodes) {
33+
final Pointer<Utf16> keyPath = TEXT('\\StringFileInfo\\$code\\$key');
34+
final Pointer<Uint32> length = calloc<Uint32>();
35+
final Pointer<Pointer<Utf16>> valueAddress = calloc<Pointer<Utf16>>();
36+
try {
37+
if (VerQueryValue(versionInfo, keyPath, valueAddress, length) != 0) {
38+
return valueAddress.value.toDartString();
39+
}
40+
} finally {
41+
calloc.free(keyPath);
42+
calloc.free(length);
43+
calloc.free(valueAddress);
3644
}
37-
return valueAddress.value.toDartString();
38-
} finally {
39-
calloc.free(keyPath);
40-
calloc.free(length);
41-
calloc.free(valueAddress);
4245
}
46+
return null;
4347
}
4448
}
4549

0 commit comments

Comments
 (0)