Skip to content

Commit

Permalink
注册的Autorun键值在Win10上无反应,是子键和项的问题。
Browse files Browse the repository at this point in the history
Desc: RegSetValue只能修改注册表键的默认项,对于非默认项无法修改,这种方式注册到Run的子键中在Win10下自启动不可用,需要直接在Run下新建一个非默认项值,使用RegSetValueEx设置的是子项而不是子键,此处应修改为RegSetValueEx。配套的应使用RegDeleteValue删除项。
Type: Feature
Link: NA
  • Loading branch information
KondeU committed Aug 20, 2021
1 parent 30a23d1 commit da5cd4e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions AutoDiskCopier_v3/src/AutoDiskCopier.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class CAutoDiskCopier
RegOpenKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), &hReg);
if (m_bAutorun)
{
if (ERROR_SUCCESS == RegSetValue(hReg, TEXT("AutoDiskCopier"), REG_SZ, szFilePath, (lstrlen(szFilePath) + 1) * sizeof(TCHAR)))
if (ERROR_SUCCESS == RegSetValueEx(hReg, TEXT("AutoDiskCopier"), 0, REG_SZ, (BYTE*)szFilePath, (lstrlen(szFilePath) + 1) * sizeof(TCHAR)))
{
m_bLastAutorun = m_bAutorun;
}
Expand All @@ -208,7 +208,7 @@ class CAutoDiskCopier
}
else
{
if (ERROR_SUCCESS == RegDeleteKey(hReg, TEXT("AutoDiskCopier")))
if (ERROR_SUCCESS == RegDeleteValue(hReg, TEXT("AutoDiskCopier")))
{
m_bLastAutorun = m_bAutorun;
}
Expand Down

0 comments on commit da5cd4e

Please sign in to comment.