注册表桌面路径中文乱码问题

This commit is contained in:
2022-11-14 10:00:58 +08:00
parent c33a1aca8f
commit 887dce0a36
3 changed files with 17 additions and 12 deletions

View File

@ -159,7 +159,7 @@ let main ={
}
},
{
label:'版本号:2.2.0',
label:'版本号:2.2.1',
icon: respath + path.sep+ "static"+ path.sep+"images"+ path.sep+"paste.png",
},]
});
@ -167,4 +167,4 @@ let main ={
}
module.exports=main
module.exports=main

View File

@ -95,17 +95,20 @@
const ws = require('windows-shortcuts');
const os=require('os');
const process = require('child_process');
const iconv = require('iconv-lite');
const encoding = 'cp936';
const binaryEncoding = 'binary';
const keyPath = 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders';//选择要修改或者保存或者删除的路径(操作路径)
let desktop;
let ele = require('electron');
let ipcRenderer = ele.ipcRenderer;
window.$ = window.jquery = require('jquery');
let update_info = {};
process.exec(`REG QUERY "${keyPath}" /v Desktop`, function (error, stdout, stderr) {
process.exec(`REG QUERY "${keyPath}" /v Desktop`, {encoding: binaryEncoding}, function (error, stdout, stderr) {
if (error != null) {
console.log('获取注册表桌面路径失败,异常如下:' + error);
} else {
let value = stdout.split(" ");
let value = iconv.decode(new Buffer(stdout, binaryEncoding), encoding).split(" ");
desktop = value[value.length - 1].replace(/^\s*|\s*$/g, ""); //获取注册表实际值并去除首尾空格
}
});