要怎麼把
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
"xxx"="xxx"
寫到登錄檔裡?
2005-11-30 15:17:00 · 2 個解答 · 發問者 Anonymous in 電腦與網際網路 ➔ 程式設計
希望月上柳梢頭能夠再更詳細一點
2005-12-08 15:31:08 · update #1
'----以下在模組裡----
'---Registry API 宣告---
Enum ValueType
REG_NONE = 0
REG_SZ = 1
REG_EXPAND_SZ = 2
REG_BINARY = 3
REG_DWORD = 4
REG_DWORD_BIG_ENDIAN = 5
REG_MULTI_SZ = 7
End Enum
Enum RootKey
HKEY_CURRENT_USER = &H80000001
End Enum
Enum ErrorCode
ERROR_SUCCESS = 0&
ERROR_MORE_DATA = 234&
End Enum
'-----------------------
'---登錄檔操作---
Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public 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
Public Function SetValue(ByVal hKey As Long, ByVal ValueName As String, ByVal vType As Long, Value As Variant, Optional ByVal lenValue As Integer) As Boolean
Dim ret As Long, bArr() As Byte
On Error GoTo ErrorExit
Select Case vType
Case REG_SZ, REG_EXPAND_SZ, REG_MULTI_SZ
ret = RegSetValueEx(hKey, ValueName, 0&, vType, ByVal CStr(Value), LenB(StrConv(Value, vbFromUnicode)) + 1)
Case REG_DWORD, REG_DWORD_BIG_ENDIAN
ret = RegSetValueEx(hKey, ValueName, 0&, vType, CLng(Value), 4)
Case REG_BINARY
Dim i As Integer
ReDim bArr(0 To lenValue - 1)
For i = 0 To lenValue - 1
bArr(i) = Value(i)
Next
ret = RegSetValueEx(hKey, ValueName, 0&, vType, bArr(0), lenValue)
End Select
SetValue = (ret = 0)
ErrorExit:
End Function
Public Sub ByteArrayToString(bArray() As Byte, S As String)
S = StrConv(bArray, vbUnicode)
End Sub
'---底下在Form1裡
Private Sub Form_Load()
Dim aa As Boolean, bytary() As Byte, str5 As String, hKey As Long
aa = RegOpenKey(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Run", hKey)
aa = SetValue(hKey, "xxx", REG_SZ, "xxx")
Call RegCloseKey(hKey)
Unload Me
End Sub
'---差一點放不下,而且我還刪除了一些不要的宣告與函式
2005-11-30 15:53:55 · answer #1 · answered by 蛋糕先生 2 · 0⤊ 0⤋
Set RegEdit = CreateObject("WScript.Shell")
RegEdit.RegWrite "HKEY_LOCAL_MACHINE\SoftWare\MicroSoft\Windows\CurrentVersion\Run\PADSEQ", 1& , "REG_DWORD"
2005-12-05 17:13:58 · answer #2 · answered by ? 5 · 0⤊ 0⤋