{"id":42860,"date":"2023-09-28T07:00:47","date_gmt":"2023-09-27T23:00:47","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=42860"},"modified":"2023-09-28T07:00:47","modified_gmt":"2023-09-27T23:00:47","slug":"exrqjzcb","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/42860.html","title":{"rendered":"Electron\u5199\u5165\u5168\u5c40\u6ce8\u518c\u8868"},"content":{"rendered":"
Electron\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u6846\u67b6\uff0c\u53ef\u4ee5\u7528\u6765\u5f00\u53d1\u8de8\u5e73\u53f0\u7684\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u7684\u6838\u5fc3\u662fChromium\u548cNode.js\uff0c\u53ef\u4ee5\u4f7f\u7528HTML\uff0cCSS\u548cJavaScript\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Electron\u5199\u5165\u5168\u5c40\u6ce8\u518c\u8868\uff0c\u4ee5\u53ca\u5b9e\u73b0\u6b64\u529f\u80fd\u7684\u6b65\u9aa4\u3002<\/p>\n
\u5168\u5c40\u6ce8\u518c\u8868\u662f\u6307Windows\u7cfb\u7edf\u4e0a\u7684\u4e00\u4e2a\u7ed3\u6784\u5316\u7684\u6570\u636e\u5e93\uff0c\u7528\u4e8e\u5b58\u50a8\u7cfb\u7edf\u548c\u5e94\u7528\u7a0b\u5e8f\u7684\u914d\u7f6e\u4fe1\u606f\uff0c\u5b83\u662f\u4e00\u4e2a\u5168\u5c40\u6027\u7684\u6570\u636e\u5b58\u50a8\u7a7a\u95f4\uff0c\u6bcf\u4e2a\u7528\u6237\u90fd\u53ef\u4ee5\u67e5\u770b\u548c\u4fee\u6539\u5168\u5c40\u6ce8\u518c\u8868\u4e2d\u7684\u6570\u636e\u3002<\/p>\n
\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5electron-windows-registry\u6a21\u5757\uff0c\u5b83\u662f\u4e00\u4e2a\u7528\u4e8e\u5728Electron\u4e2d\u8bbf\u95eeWindows\u6ce8\u518c\u8868\u7684\u6a21\u5757\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7npm\u5b89\u88c5\u5b83\uff1a<\/p>\n
npm install electron-windows-registry<\/code><\/pre>\n \u6b65\u9aa42\uff1a\u5f15\u5165electron-windows-registry\u6a21\u5757<\/h3>\n
\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u5728\u6211\u4eec\u7684\u5e94\u7528\u7a0b\u5e8f\u4e2d\u5f15\u5165electron-windows-registry\u6a21\u5757\uff1a<\/p>\n
const Registry = require('electron-windows-registry');<\/code><\/pre>\n \u6b65\u9aa43\uff1a\u83b7\u53d6\u5168\u5c40\u6ce8\u518c\u8868<\/h3>\n
\u7136\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Registry.getGlobalRegistry()\u51fd\u6570\u6765\u83b7\u53d6\u5168\u5c40\u6ce8\u518c\u8868\uff1a<\/p>\n
const globalRegistry = Registry.getGlobalRegistry();<\/code><\/pre>\n \u6b65\u9aa44\uff1a\u5199\u5165\u5168\u5c40\u6ce8\u518c\u8868<\/h3>\n
\u6700\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528globalRegistry.setValue()\u51fd\u6570\u6765\u5199\u5165\u5168\u5c40\u6ce8\u518c\u8868\uff1a<\/p>\n
globalRegistry.setValue('key', 'value');<\/code><\/pre>\n\u603b\u7ed3<\/h2>\n
\u672c\u6587\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528Electron\u5199\u5165\u5168\u5c40\u6ce8\u518c\u8868\u7684\u6b65\u9aa4\uff0c\u9996\u5148\u6211\u4eec\u9700\u8981\u5b89\u88c5electron-windows-registry\u6a21\u5757\uff0c\u7136\u540e\u5f15\u5165\u5b83\uff0c\u63a5\u7740\u83b7\u53d6\u5168\u5c40\u6ce8\u518c\u8868\uff0c\u6700\u540e\u4f7f\u7528globalRegistry.setValue()\u51fd\u6570\u5199\u5165\u5168\u5c40\u6ce8\u518c\u8868\u3002<\/strong>\u901a\u8fc7\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u4f7f\u7528Electron\u5199\u5165\u5168\u5c40\u6ce8\u518c\u8868\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Electron\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u6846\u67b6\uff0c\u53ef\u4ee5\u7528\u6765\u5f00\u53d1\u8de8\u5e73\u53f0\u7684\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u7684\u6838\u5fc3\u662fChromium\u548cNode.js\uff0c\u53ef\u4ee5\u4f7f\u7528HTML\uff0cCSS\u548cJavaScript\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f<\/p>\n","protected":false},"author":1,"featured_media":4132,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[305],"class_list":["post-42860","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-dzjs"],"_links":{"self":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/42860","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/comments?post=42860"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/42860\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media\/4132"}],"wp:attachment":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media?parent=42860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=42860"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=42860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}