以下是引用su0527在2018-2-27 18:34:36的发言:
设置后,如何取消开机自启,也就是复原。
取消可以用RegDeleteValue直接删除掉
** HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
#DEFINE HKEY_CURRENT_USER -2147483647
DECLARE LONG RegOpenKey IN Advapi32 LONG, STRING@, LONG@
DECLARE LONG RegCloseKey IN Advapi32 LONG
DECLARE LONG RegSetValueEx IN Advapi32 LONG, STRING@, LONG, LONG, STRING@, LONG
DECLARE LONG RegDeleteValue IN Advapi32 LONG, STRING@
** IF myStartup("test", "C:\temp\test.exe")
** ? "设置成功"
** ENDIF
IF myStartup("test")
? "取消成功"
ENDIF
FUNCTION myStartup(cValName, cFileName)
LOCAL hKey, ret
hKey = 0
ret = RegOpenKey(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Run", @hKey)==0
IF ret
IF !EMPTY(cFileName)
ret = FILE(cFileName)
IF ret
ret = RegSetValueEx(hKey, cValName, 0, 1, cFileName, LEN(cFileName))==0
ENDIF
ELSE
ret = RegDeleteValue(hKey, cValName)==0
ENDIF
RegCloseKey(hKey)
ENDIF
RETURN ret
ENDFUNC