在VB中如何讓程序在啟動時同時啟動我的程序

singwolf007 2003-05-14 09:57:00
在DELPHI中很好做,但在VB中就不知道如何做了,最好有代碼
...全文
10 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
SnowOct 2003-05-15
跟进学习
回复
Vii 2003-05-15
up
回复
nik_Amis 2003-05-15
用API了,搜索一下,太多了
回复
netbandit 2003-05-15
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, 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
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long

If Check1.Value = 1 Then '检查是否选中自动运行项
rc1 = RegOpenKeyEx(HKEY_LOCAL_MACHINE, gREGKEYSTARTUP, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key
str1 = App.Path & "\juniozhu.exe" 'juniozhu.exe就是指你要开机时运行的程序
rc1 = RegSetValueEx(hKey, "juniozhu", 0, REG_SZ, ByVal str1, Len(str1) + 1) '传递子符子串时前面须加上传值类型ByVal,方能传递字符串
Else
rc1 = RegOpenKeyEx(HKEY_LOCAL_MACHINE, gREGKEYSTARTUP, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key
rc1 = RegDeleteValue(hKey, "juniozhu")
End If
前面三个是用的到的API函数,其它的你自己去看看,我想你应该可以看的懂:)
回复
singwolf007 2003-05-15
沒有人知道嗎
回复
singwolf007 2003-05-14
就是把下面這段程序譯成VB就可以了,換句話說就是在VB中如何寫到註冊表HKEY_LOCAL_MACHINE下面的'SOFTWARE\Microsoft\Windows\CurrentVersion\Run位置!

RegF:=TRegistry.Create;
RegF.RootKey:=HKEY_LOCAL_MACHINE;
try
RegF.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',True);
RegF.WriteString('mypos3000',application.exename);
except
application.MessageBox('寫入成功','系統提示',mb_ok+mb_iconinformation);
end;
RegF.CloseKey;
另:加問
如何使程序放在右下解的任備欄中
回复
hansong_ll 2003-05-14
不知你是不是想这样?
Shell(xxx.exe)
回复
griefforyou 2003-05-14
?什么意思
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7489

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2003-05-14 09:57
社区公告
暂无公告