|
程序说明:
要使程序每次启动时自动地运行可以在注册表文件
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run写入启动信息,这样在
Windows每次启动时都会自动地动行
使用 RegCreateKey 取的
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run 的 hKey 的值
使用 RegSetValueEx 在 hKey 下写入一个以"我的记事本"作为名,以 "Notepad.exe" 作为值的启动
所有的控件:
Command1 Command2
程序代码:
Modul31 Public Declare Function RegCloseKey Lib "advapi32.dll"
(ByVal hKey As Long) As Long Public Declare Function RegCreateKey Lib
"advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey
As String, phkResult 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 ' Note that if you declare the lpData parameter as
String, you must pass it By Value.
Public Const HKEY_CURRENT_USER = &H80000001
Public Const REG_SZ = 1
Form1 Private Sub Command1_Click() Unload Me End Sub
Private Sub Command2_Click() Dim SubKey As String Dim Exe As
String Dim hKey As Long
SubKey = "Software\Microsoft\Windows\CurrentVersion\Run" Exe =
"Notepad.exe" RegCreateKey HKEY_CURRENT_USER, SubKey, hKey
RegSetValueEx hKey, "我的记事本", 0, REG_SZ, ByVal Exe,
LenB(StrConv(Exe, vbFromUnicode)) + 1
RegCloseKey hKey
End Sub
Private Sub Form_Load()
End Sub 156
[系统软件]windows下Apache+php+mysql的安装与配置图解 [操作系统]在Windows中玩转Linux操作系统 [操作系统]死马还当活马医:6种方法挽救Windows系统 [聊天工具]四大更新 Windows Live Msn 8.1评测 [聊天工具]Windows Live Messenger最新0683版亮相_联络工具_… [聊天工具]Windows Live Mail招人爱的N个理由_联络工具_Wind… [聊天工具]Windows Live Mail Desktop多图欣赏_联络工具_Win… [聊天工具]OE老了 微软开发新邮件客户端取而代之_联络工具 [聊天工具]Windows Live Messenger中文版试用报告(一)__天极… [聊天工具]Windows Live Messenger 8 Beta1高清图赏__天极Ye…
|