永发信息网

VB紧急问题!

答案:2  悬赏:70  手机版
解决时间 2021-04-16 09:21
  • 提问者网友:泪痣哥哥
  • 2021-04-15 22:57

这个程序是把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
如上代码在进行编入程序到注册表为什么运行时为提示如图所示:

请高手指点问题所在处:在下感激不尽…………

最佳答案
  • 五星知识达人网友:你哪知我潦倒为你
  • 2021-04-16 00:23

aa = Text1
bb = Text2
是不是改成:


aa = Text1.Text


bb = Text2.Text

全部回答
  • 1楼网友:傲气稳了全场
  • 2021-04-16 01:10

Const HKEY_LOCAL_MACHINE = &H80000002

在声明中加这句,就可以了

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯