这个程序是把text1和text2的内容分别通过注入启动按钮来为windows指定一个自启动项到注册表中,从而到达预期的效果,程序代码如下:
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Sub SetMyValue(hKey As Long, strPath As String, strValue As String, strData As String)
Dim keyHandle
Dim lResult As Long
lResult = RegCreateKey(hKey, strPath, keyHandle)
lResult = RegSetValueEx(keyHandle, strValue, 0, REG_SZ, ByVal strData, Len(strData))
lResult = RegCloseKey(keyHandle)
End Sub
Private Sub Command1_Click()
Dim aa As String
Dim bb As String
aa = Text1
bb = Text2
SetMyValue HKEY_LOCAL_MACHINE, SOFTWARE \ Microsoft \ Windows \CurrentVersion \ Run, aa, bb
End Sub
如上代码在进行编入程序到注册表为什么运行时为提示如图所示:
请高手指点问题所在处:在下感激不尽…………