Tải bản đầy đủ (.docx) (1 trang)

Các chiêu thức trong lập trình Chương trình khởi động cùng với Windowns home

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (64.06 KB, 1 trang )

Chương trình khởi động cùng với Windowns home
Xuất xứ : www.pscode.com
Binh khí sử dụng : Một Module
Đoạn mã : (Trong đoạn mạ còn có thành phần ngừng ngắt chương trình khởi động cùng Windown )
Module :
Option Explicit
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As
Long
Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA"
(ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
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
Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA"
(ByVal hKey As Long, ByVal lpValueName As String) As Long
Public Const REG_SZ = 1 ' Unicode nul terminated string
Public Const REG_BINARY = 3 ' Free form binary
Public Const HKEY_CURRENT_USER = &H80000001
Sub SaveString(hKey As Long, strPath As String, strValue As String, strData
As String)
Dim Ret
RegCreateKey hKey, strPath, Ret
RegSetValueEx Ret, strValue, 0, REG_SZ, ByVal strData, Len(strData)
RegCloseKey Ret
End Sub
Sub DelSetting(hKey As Long, strPath As String, strValue As String)
Dim Ret
RegCreateKey hKey, strPath, Ret
RegDeleteValue Ret, strValue
RegCloseKey Ret
End Sub


Form :
Dim AppVirus As String
Private Sub Form_Load()
If Len(App.Path) <> 3 Then
AppVirus = App.Path + "\" + App.exename + (“.exe”)
Else
AppVirus = App.Path + App.exename + (“.exe”)
End If
SaveString HKEY_CURRENT_USER,
"Software\Microsoft\Windows\CurrentVersion\Run", "DungCoi", AppVirus
‘ DelSetting HKEY_CURRENT_USER,
"Software\Microsoft\Windows\CurrentVersion\Run", "DungCoi"
End Sub
‘Chú ý : Phần DungCoi ở đây là Tên Key
‘ Phần AppVirus là đường dẫn File của bạn

×