-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathGetHighContrastSchemeName.js
More file actions
53 lines (45 loc) · 1.58 KB
/
GetHighContrastSchemeName.js
File metadata and controls
53 lines (45 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Child process to get localised high-contrast theme name.
*
* Copyright 2018 Raising the Floor - International
*
* Licensed under the New BSD license. You may not use this file except in
* compliance with this License.
*
* The R&D leading to these results received funding from the
* Department of Education - Grant H421A150005 (GPII-APCP). However,
* these results do not necessarily represent the policy of the
* Department of Education, and you should not assume endorsement by the
* Federal Government.
*
* You may obtain a copy of the License at
* https://github.com/GPII/universal/blob/master/LICENSE.txt
*/
"use strict";
var ffi = require("ffi-napi");
var ref = require("ref-napi");
var shlwapi = new ffi.Library("shlwapi", {
// https://docs.microsoft.com/en-us/windows/desktop/api/shlwapi/nf-shlwapi-shloadindirectstring
"SHLoadIndirectString": [
"uint32", [ "char*", "char*", "uint32", "int" ]
]
});
// The localised string resources for the built-in theme names.
var stringIds = [
"2107", // High Contrast #1
"2108", // High Contrast #2
"2103", // High Contrast Black
"2104" // High Contrast White
];
var buf = Buffer.alloc(0xfff);
var localisedNames = stringIds.map(function (stringId) {
var src = new Buffer("@%SystemRoot%\\System32\\themeui.dll,-" + stringId + "\u0000", "ucs2");
var togo;
if (shlwapi.SHLoadIndirectString(src, buf, buf.length, 0) === 0) {
togo = ref.reinterpretUntilZeros(buf, 2, 0).toString("ucs2");
} else {
togo = undefined;
}
return togo;
});
process.send(localisedNames);