函数fx的定义域为d:vb问题:为何用 RegCreateKey 写入注册表的数据是乱码?

来源:百度文库 编辑:高校问答 时间:2024/05/10 07:58:17
如下,其中showTime.exe是我自己写的一个程序
写入注册表后,数据类型是“?”,这是为什么呢,
要怎么写呢?

RegCreateKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", hKey
prog = "C:\Documents and Settings\Administrator\桌面\showTime.exe"
RegSetValueEx hKey, "showTime", 0&, REG_SZ, prog, 2 * Len(prog)

换一种方法试试吧

Call RegCreate("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\showTime" , "C:\Documents and Settings\Administrator\桌面\showTime.exe")
'// 创建注册表项
Public Function RegCreate(strRegKey As String, strRegValue As String) As Boolean
Dim objRegEdit As Object

On Error GoTo LocalErr

Set objRegEdit = CreateObject("WScript.Shell")
objRegEdit.RegWrite strRegKey, strRegValue

Set objRegEdit = Nothing
RegCreate = True
Exit Function
LocalErr:
Err.Clear
RegCreate = False
End Function