desktop / registry-js Goto Github PK
View Code? Open in Web Editor NEWA simple and opinionated library for working with the Windows registry
License: MIT License
A simple and opinionated library for working with the Windows registry
License: MIT License
https://github.com/ironSource/node-regedit
I can see you have two package comparisons in the readme, can you compare to the regedit too?
It doesn't require .node native module, so won't cause a problem like
And build errors like tiddly-gittly/TidGi-Desktop#117 (comment)
I currently copy the code from Desktop/Desktop desktop/desktop#13133 , but the exact code won't work on my electron forge setup, makes me wonder whether a package without native module is better...
Node 12 has marked some of these APIs as deprecated:
c:\projects\lean-mean-registry-client\src\main.cc(64): warning C4996: 'v8::Object::Set': was declared deprecated [C:\projects\lean-mean-registry-client\build\registry.vcxproj]
c:\users\appveyor\.node-gyp\12.3.1\include\node\v8.h(3358): note: see declaration of 'v8::Object::Set'
c:\projects\lean-mean-registry-client\src\main.cc(65): warning C4996: 'v8::Object::Set': was declared deprecated [C:\projects\lean-mean-registry-client\build\registry.vcxproj]
c:\users\appveyor\.node-gyp\12.3.1\include\node\v8.h(3358): note: see declaration of 'v8::Object::Set'
c:\projects\lean-mean-registry-client\src\main.cc(66): warning C4996: 'v8::Object::Set': was declared deprecated [C:\projects\lean-mean-registry-client\build\registry.vcxproj]
c:\users\appveyor\.node-gyp\12.3.1\include\node\v8.h(3358): note: see declaration of 'v8::Object::Set'
c:\projects\lean-mean-registry-client\src\main.cc(76): warning C4996: 'v8::Object::Set': was declared deprecated [C:\projects\lean-mean-registry-client\build\registry.vcxproj]
c:\users\appveyor\.node-gyp\12.3.1\include\node\v8.h(3358): note: see declaration of 'v8::Object::Set'
c:\projects\lean-mean-registry-client\src\main.cc(77): warning C4996: 'v8::Object::Set': was declared deprecated [C:\projects\lean-mean-registry-client\build\registry.vcxproj]
c:\users\appveyor\.node-gyp\12.3.1\include\node\v8.h(3358): note: see declaration of 'v8::Object::Set'
c:\projects\lean-mean-registry-client\src\main.cc(78): warning C4996: 'v8::Object::Set': was declared deprecated [C:\projects\lean-mean-registry-client\build\registry.vcxproj]
c:\users\appveyor\.node-gyp\12.3.1\include\node\v8.h(3358): note: see declaration of 'v8::Object::Set'
See atom/node-keytar#186 for a suggested way to migrate to the recommended API, using Nan::GetCurrentContext()
Looks great
Originally posted by @Plentywolf in AdguardTeam/companiesdb#208 (review)
Packages are copied from the content-addressable store to the virtual store.
Content-addressable store is at: /home/snowy/.local/share/pnpm/store/v3
Virtual store is at: node_modules/.pnpm
Progress: resolved 1452, reused 1450, downloaded 0, added 1452, done
node_modules/.pnpm/@[email protected]/node_modules/@bitdisaster/exe-icon-extractor: Running install script, failed in 792ms (skipped as optional)
node_modules/.pnpm/[email protected]/node_modules/registry-js: Running install script, failed in 1.4s
.../node_modules/registry-js install$ prebuild-install || node-gyp rebuild
│ prebuild-install WARN install No prebuilt binaries found (target=3 runtime=napi arch=x64 libc= platform=linux)
│ gyp info it worked if it ends with ok
│ gyp info using [email protected]
│ gyp info using [email protected] | linux | x64
│ gyp info find Python using Python version 3.10.6 found at "/usr/bin/python3"
│ gyp info spawn /usr/bin/python3
│ gyp info spawn args [
│ gyp info spawn args '/home/snowy/.nvm/versions/node/v18.15.0/lib/node_modules/pnpm/dist/node_modules/node-gyp/gyp/gyp_main.py',
│ gyp info spawn args 'binding.gyp',
│ gyp info spawn args '-f',
│ gyp info spawn args 'make',
│ gyp info spawn args '-I',
│ gyp info spawn args '/home/snowy/TidGi-Desktop/node_modules/.pnpm/[email protected]/node_modules/registry-js/build/config.gypi',
│ gyp info spawn args '-I',
│ gyp info spawn args '/home/snowy/.nvm/versions/node/v18.15.0/lib/node_modules/pnpm/dist/node_modules/node-gyp/addon.gypi',
│ gyp info spawn args '-I',
│ gyp info spawn args '/home/snowy/.cache/node-gyp/18.15.0/include/node/common.gypi',
│ gyp info spawn args '-Dlibrary=shared_library',
│ gyp info spawn args '-Dvisibility=default',
│ gyp info spawn args '-Dnode_root_dir=/home/snowy/.cache/node-gyp/18.15.0',
│ gyp info spawn args '-Dnode_gyp_dir=/home/snowy/.nvm/versions/node/v18.15.0/lib/node_modules/pnpm/dist/node_modules/node-gyp',
│ gyp info spawn args '-Dnode_lib_file=/home/snowy/.cache/node-gyp/18.15.0/<(target_arch)/node.lib',
│ gyp info spawn args '-Dmodule_root_dir=/home/snowy/TidGi-Desktop/node_modules/.pnpm/[email protected]/node_modules/registry-js',
│ gyp info spawn args '-Dnode_engine=v8',
│ gyp info spawn args '--depth=.',
│ gyp info spawn args '--no-parallel',
│ gyp info spawn args '--generator-output',
│ gyp info spawn args 'build',
│ gyp info spawn args '-Goutput_dir=.'
│ gyp info spawn args ]
│ gyp info spawn make
│ gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
│ make: 进入目录“/home/snowy/TidGi-Desktop/node_modules/.pnpm/[email protected]/node_modules/registry-js/build”
│ SOLINK_MODULE(target) Release/obj.target/registry.node
│ make: g++: 没有那个文件或目录
│ make: *** [registry.target.mk:22:Release/obj.target/registry.node] 错误 127
│ make: 离开目录“/home/snowy/TidGi-Desktop/node_modules/.pnpm/[email protected]/node_modules/registry-js/build”
│ gyp ERR! build error
│ gyp ERR! stack Error: `make` failed with exit code: 2
│ gyp ERR! stack at ChildProcess.onExit (/home/snowy/.nvm/versions/node/v18.15.0/lib/node_modules/pnpm/dist/node_modules/node-gyp/lib/build.js:203:23)
│ gyp ERR! stack at ChildProcess.emit (node:events:513:28)
│ gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12)
│ gyp ERR! System Linux 5.15.0-56-generic
│ gyp ERR! command "/home/snowy/.nvm/versions/node/v18.15.0/bin/node" "/home/snowy/.nvm/versions/node/v18.15.0/lib/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
│ gyp ERR! cwd /home/snowy/TidGi-Desktop/node_modules/.pnpm/[email protected]/node_modules/registry-js
│ gyp ERR! node -v v18.15.0
│ gyp ERR! node-gyp -v v9.4.0
│ gyp ERR! not ok
└─ Failed in 1.5s at /home/snowy/TidGi-Desktop/node_modules/.pnpm/[email protected]/node_modules/registry-js
ELIFECYCLE Command failed with exit code 1.
https://github.com/desktop/registry-js/blob/master/src/main.cc#L109
This line allocates an array of fixed size, which is then populated with values on these lines:
https://github.com/desktop/registry-js/blob/master/src/main.cc#L133:L149
Only REG_SZ, REG_EXPAND_SZ and REG_DWORD is supported.
If an unsupported value is enumerated, this produces an array in typescript that could end up looking like this:
[{ ... REG_DWORD value }, undefined, { ...REG_SZ value }]
The typings does not reflect that undefined is a possibility. Either the typings should change, or the array returned from the EnumerateValues function should not return empty values.
https://github.com/electron/electron/releases/tag/v7.0.0
I don't have a clue what's needed to make registry-js work with Electron 7, but just looking at #164 it looks like it is as simple as just adding -t 7.0.0
to prebuild-electron
and prebuild-electron-ia32
and update the node-abi
dependency?
Is there something else that's needed?
But they don't have to be, since you can shove any old data in there. See Raymond Chen's blog for more details: https://blogs.msdn.microsoft.com/oldnewthing/20040824-00/?p=38063
To fix this, we need to pass the length value to the CreateEntry
method and use it when instantiating the strings. Sadly, the method must test the last character and then adjust the length based on that.
..\src\main.cc(161): warning C4244: 'initializing': conversion from 'double' to 'ULONG', possible loss of data [C:\projects\lean-mean-registry-client\build\registry.vcxproj]
..\src\main.cc(166): warning C4312: 'type cast': conversion from 'ULONG' to 'HKEY' of greater size [C:\projects\lean-mean-registry-client\build\registry.vcxproj]
Creating library C:\projects\lean-mean-registry-client\build\Release\registry.lib and object C:\projects\lean-mean-registry-client\build\Release\registry.exp
This was some lazy code to get this up and running sooner - we can do better.
From the JS side, I've got a lookup that converts the string enum to the long
specified in MSDN:
Lines 70 to 83 in 50dd82e
Then, in the C++ side, we need to cast this to a HKEY
to use it with RegOpenKeyEx
:
Lines 152 to 161 in 7b0da43
These look like this in winreg.h
:
#define HKEY_CLASSES_ROOT (( HKEY ) (ULONG_PTR)((LONG)0x80000000) )
#define HKEY_CURRENT_USER (( HKEY ) (ULONG_PTR)((LONG)0x80000001) )
#define HKEY_LOCAL_MACHINE (( HKEY ) (ULONG_PTR)((LONG)0x80000002) )
#define HKEY_USERS (( HKEY ) (ULONG_PTR)((LONG)0x80000003) )
#define HKEY_PERFORMANCE_DATA (( HKEY ) (ULONG_PTR)((LONG)0x80000004) )
#define HKEY_PERFORMANCE_TEXT (( HKEY ) (ULONG_PTR)((LONG)0x80000050) )
#define HKEY_PERFORMANCE_NLSTEXT (( HKEY ) (ULONG_PTR)((LONG)0x80000060) )
Just need to figure out how to marshal these properly from V8's types...
I am developing an electron application and I need to access window registry entries.
npm install --save registry-js
It installed successfully but on run time I am getting the following error:
ERROR in ./node_modules/registry-js/build/Release/registry.node 1:2
Module parse failed: Unexpected character '�' (1:2)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
This is bad.. but didn't know how to properly do the typing stuff on this. unless I did a `getBoolean`, getNumber`, `getObject`... but, didn't want to explore more because I was just trying to do quick/dirty POC right now.
Originally posted by @tidy-dev in desktop/desktop#17386 (comment)
xref #9 (comment)
cc @danilaml
I have created a PR (#180) to add support for Electron 8 and 9.
Can someone merge this and publish to NPM?
Thanks!
Hi :) I noticed that [email protected]
dropped prebuilds for node 8 (dbceb16). Node 8 isn't EOL yet, so I'm wondering what your policy is regarding node versions and/or prebuilds, if any?
Hello,
Does this package allow for mutating/editing values/keys in the registry? Looking through the documentation, it does not seem so.
Thanks.
Getting a list of sections by a specific path. There is a demand to get a list of sections by the path HKEY_CURRENT_USERSoftware\Microsoft\Windows\CurrentVersion\Uninstall, but I don't really want to run .ps using node-child or install regedit. Is there an option to do this using registry-js, or is there no such functionality? If not, is it worth waiting for?
Example:
Get the list of sections in HKEY_CURRENT_USERSoftware\Microsoft\Windows\CurrentVersion\Uninstall\
Result: List with the names of sections
etc
c:\users\lamathe\appdata\local\temp\electron-packager\win32-x64\chime-win32-x64\resources\app\node_modules\registry-js\node_modules\node-addon-api\napi-inl.h(1393): error C3861: 'napi_object_freeze': identifier not found [C:\Users\lamathe\AppData\Local\Temp\electron-packager\win32-x64\Chime-win32-x64\resources\app\node_modules\registry-js\build\registry.vcxproj]
c:\users\lamathe\appdata\local\temp\electron-packager\win32-x64\chime-win32-x64\resources\app\node_modules\registry-js\node_modules\node-addon-api\napi-inl.h(1399): error C3861: 'napi_object_seal': identifier not found [C:\Users\lamathe\AppData\Local\Temp\electron-packager\win32-x64\Chime-win32-x64\resources\app\node_modules\registry-js\build\registry.vcxproj]
An unhandled error has occurred inside Forge:
node-gyp failed to rebuild 'C:\Users\lamathe\AppData\Local\Temp\electron-packager\win32-x64\Chime-win32-x64\resources\app\node_modules\registry-js'.
Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe
failed with exit code: 1
Error: node-gyp failed to rebuild 'C:\Users\lamathe\AppData\Local\Temp\electron-packager\win32-x64\Chime-win32-x64\resources\app\node_modules\registry-js'.
Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe
failed with exit code: 1
at ModuleRebuilder.rebuildNodeGypModule (C:\Users\lamathe\Documents\GitHub\ChimeElectron\src\ChimeElectron\node_modules\electron-rebuild\src\module-rebuilder.ts:231:13)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at Rebuilder.rebuildModuleAt (C:\Users\lamathe\Documents\GitHub\ChimeElectron\src\ChimeElectron\node_modules\electron-rebuild\src\rebuild.ts:283:5)
at Rebuilder.rebuild (C:\Users\lamathe\Documents\GitHub\ChimeElectron\src\ChimeElectron\node_modules\electron-rebuild\src\rebuild.ts:189:9)
at C:\Users\lamathe\Documents\GitHub\ChimeElectron\src\ChimeElectron\node_modules\@electron-forge\core\src\util\rebuild.ts:33:5
Error while packaging the electron app
Hi,
When I add registry-js via npm install registry-js, the program build will fail. the details log is as below:
=======================================================================
C:\code\Msp_electron>npm install registry-js --python="C:\Users\zredb\miniconda3\python.exe"
[email protected] install C:\code\Msp_electron\node_modules\registry-js
prebuild-install || node-gyp rebuild
prebuild-install WARN install unexpected end of file
C:\code\Msp_electron\node_modules\registry-js>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Program Files\nodejs\node_
modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
在此解决方案中一次生成一个项目。若要启用并行生成,请添加“-m”开关。
main.cc
win_delay_load_hook.cc
正在创建库 C:\code\Msp_electron\node_modules\registry-js\build\Release\registry.lib 和对象 C:\code\Msp_electron\node_modules\registry-js\build\Release\registry.exp
registry.vcxproj -> C:\code\Msp_electron\node_modules\registry-js\build\Release\registry.node
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\webpack-dev-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\watchpack-chokidar2\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm audit fix
to fix them, or npm audit
for detailsC:\code\Msp_electron>yarn serve
yarn run v1.21.1
$ vue-cli-service electron:serve
INFO Starting development server...
98% after emitting CopyPlugin
DONE Compiled successfully in 28118ms 9:11:15
App running at:
Note that the development build is not optimized.
To create a production build, run yarn build.
\ Bundling main process...
ERROR Failed to compile with 1 errors 9:11:18
error in ./node_modules/registry-js/build/Release/registry.node
Module parse failed: Unexpected character '�' (1:2)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
@ ./node_modules/registry-js/dist/lib/registry.js 5:6-50
@ ./node_modules/registry-js/dist/lib/index.js
@ ./src/background.js
@ multi ./src/background.js
ERROR Build failed with errors.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Any one can give some suggestion?
cool update
Originally posted by @Charlesjourdain in desktop/desktop#16624 (review)
Looks like you recently added src
directory to the .npmignore
file. The package installs just fine if there is a prebuilt binary available for the system but fails if there is no prebuilt binary available. It's also not possible to rebuild the binary with node-gyp rebuild
anymore because the package no longer includes the src directory to build from.
From #27
Need to add a test for dodgy non-null-terminated data, but I'm not sure the best way to actually get this into the registry in the first place, since REG.EXE is going to do it correctly. Can we add adjunct C++ programs to the test code somehow?
@Porges what your preferred C++ test framework for this sort of thing?
Need a better name for this too
Hi
I just updated my electron project from 5 to 6 and get the following error when running npm install:
> node postinstall
• electron-builder version=21.2.0
• loaded configuration file=C:\project\electron-builder.json
• rebuilding native dependencies [email protected] platform=win32 arch=x64
• install prebuilt binary name=registry-js version=1.8.0 platform=win32 arch=x64
• build native dependency from sources name=registry-js
version=1.8.0
platform=win32
arch=x64
reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
error=C:\project\node_modules\node-abi\index.js:30
throw new Error('Could not detect abi for version ' + target + ' and runtime ' + runtime + '. Updating "node-abi" might help solve this issue if it is a new release of ' + runtime)
^
Error: Could not detect abi for version 6.0.0 and runtime electron. Updating "node-abi" might help solve this issue if it is a new release of electron
...
I have removed my node_modules folder and updated to the latest version of registry-js (1.8.0) but still get the error. Not sure if I have missed something else... Any suggestion?
This aligns with desktop/desktop
and desktop/dugite
.
When I build my electron application I get the following output, where it says it's unable to download registry-js-v1.12.0-electron-v82-win32-x64.tar.gz.
I don't know if it's because it can access cached builds but I don't notice any problems running my application after it has been built.
Where does it get that url?
• electron-builder version=22.8.1 os=10.0.19041
• loaded configuration file=C:\dev\electron-app\electron-builder.json
• writing effective config file=release\builder-effective-config.yaml
• rebuilding native dependencies [email protected] platform=win32 arch=x64
• install prebuilt binary name=registry-js version=1.12.0 platform=win32 arch=x64
• build native dependency from sources name=registry-js
version=1.12.0
platform=win32
arch=x64
reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
error=prebuild-install info begin Prebuild-install version 5.3.5
prebuild-install WARN install prebuilt binaries enforced with --force!
prebuild-install WARN install prebuilt binaries may be out of date!
prebuild-install info looking for cached prebuild @ C:\Users\me\AppData\Roaming\npm-cache\_prebuilds\52c192-registry-js-v1.12.0-electron-v82-win32-x64.tar.gz
prebuild-install http request GET https://github.com/desktop/registry-js/releases/download/v1.12.0/registry-js-v1.12.0-electron-v82-win32-x64.tar.gz
prebuild-install http 404 https://github.com/desktop/registry-js/releases/download/v1.12.0/registry-js-v1.12.0-electron-v82-win32-x64.tar.gz
prebuild-install WARN install No prebuilt binaries found (target=10.1.3 runtime=electron arch=x64 libc= platform=win32)
Can you use https://docs.npmjs.com/cli/v10/configuring-npm/package-json#os to limit it to only install (and gpy build) on windows?
Because it breaks mac and linux build, if use with
"pnpm": {
"overrides": {
"node-abi": "latest",
"prebuild-install": "latest"
},
which is required to fix
Error: Could not detect abi for version 28.1.0 and runtime electron. Updating "node-abi" might help solve this issue if it is a new release of electron - Google Search
But if override node-abi to latest, I get error like #224 on mac and linux builds.
It's fairly straight-forward with prebuild
and greatly reduces support requests. I can help if you're interested.
And many thanks for registry-js
! It's so much better than messing with reg.exe
, FFI or JScript. I'm using it in win-detect-browsers
now, with a 2x performance boost.
PS. Which node versions are supported? My test matrix includes 6, 8, 9 and 10 - no problems so far.
It would be great to be able to subscribe to notifications via RegNotifyChangeKeyValue.
Example use case: switching between dark and light mode on Windows when the system setting is changed.
No wrapper for RegEnumKeyEx.
I get syntax error if i use this syntax:
import { enumerateValues, HKEY, RegistryValueType } from 'registry-js'
How can I use the module like below?
const { enumerateValues, HKEY, RegistryValueType } = require('registry-js');
I am writing an electron application. All source codes are written in node require style, uses module.exports. Could anyone help me?
Is there any approach to query 32-bit application data?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.