VB开机自动启动问题

来源:百度知道 编辑:UC知道 时间:2024/06/08 02:36:42
Dim strString As String
Dim keyhand As Long
Dim r As Long
strString = App.Path & "\" & App.EXEName & ".exe"
r = RegCreateKey(HKEY_LOCAL_MACHINE, "software\microsoft\windows\currentversion\run", keyhand)
r = RegSetValueEx(keyhand, "jsjuq", 0, REG_SZ, ByVal strString, Len(strString))
r = RegCloseKey(keyhand)

为什么这段代码运行时,提示RegCreateKey子程序或函数未定义。怎么解决

这是 API函数,需要事先声明的

Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long

xchbyc
是正解哦