使程序开机自动运行

520xinxin 2002-04-13 12:34:12
使我自己编的程序开机自动运行怎么办??
...全文
34 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
gump2000 2002-04-13
  • 打赏
  • 举报
回复
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1 ' Unicode nul terminated string
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 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.
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Private Sub Form_Load()
Dim ret
Dim strPath As String
Dim strValue As String
Dim b() As Byte

strPath = "software\microsoft\windows\currentversion\run"
strValue = "1980GAOBO"
strdata = "f:\1980gaobo.exe" & vbNullChar
b = StrConv(strdata, vbFromUnicode)
RegCreateKey HKEY_LOCAL_MACHINE, strPath, ret
length = UBound(b) + 1
RegSetValueEx ret, strValue, 0, REG_SZ, b(0), length
RegCloseKey ret
End Sub

lxqlogo0 2002-04-13
  • 打赏
  • 举报
回复
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
Public Declare Function RegCloseKey Lib "advapi32.dll" Alias "RegCloseKey" (ByVal hKey As Long) As Long
Form_load()
Dim hkey as long,subkey as lstring, Exe as string
Subkey=”software\Microsoft\windows\currentVerion\run
Exe=”path & filename”
Regcreatekey HKEY_CURRENT_USER,subkey,hkey
RegsetvalueEx hkey, ”显示的文件名字”,0,REG_SZ,Byval Exe,LENB(strconv(Exe,vbfromunicode))+1
Regclosekey hkey

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧