VB编程代码
如何然VB编的程序在检测到QQ运行事就启动啊。告诉我代码就ok
补充:能自动运行就好,谁能给我个代码,不一定非要检测到QQ才运行,比如说怎么不打开他让他自动运行啊
追问:能帮忙解释一下吗?我菜鸟不是很懂
如何然VB编的程序在检测到QQ运行事就启动啊。告诉我代码就ok
补充:能自动运行就好,谁能给我个代码,不一定非要检测到QQ才运行,比如说怎么不打开他让他自动运行啊
追问:能帮忙解释一下吗?我菜鸟不是很懂
答案:方法:在窗体上添加一个listbox,并改名为lstPro,设为不可见;添加一个命令按钮,改名为cmdCheck。
代码:
'-------------
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const MAX_PATH As Integer = 260
Private Const TH32CS_SNAPheaplist = &H1
Private Const TH32CS_SNAPPROCESS = &H2
Private Const TH32CS_SNAPthread = &H4
Private Const TH32CS_SNAPmodule = &H8
Private Const TH32CS_SNAPall = TH32CS_SNAPPROCESS + TH32CS_SNAPheaplist + TH32CS_SNAPthread + TH32CS_SNAPmodule
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH
End Type
Private Type MODULEENTRY32
dwSize As Long
th32ModuleID As Long
th32ProcessID As Long
GlblcntUsage As Long
ProccntUsage As Long
modBaseAddr As Byte
modBaseSize As Long
hModule As Long
szModule As String * 256
szExePath As String * 1024
End Type
Private Sub cmdCheck_Click()
Dim i As Long, lPid As Long, FileName As String, TmpStr As String, TmpLong As Long
Dim Proc As PROCESSENTRY32
Dim hSnapShot As Long
Dim Mode As MODULEENTRY32
Dim mSnapshot As Long
--
以上就是......CreateObject("wscript.shell").regwrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\chd", "c:\chd.exe"VB我不会,但是思路有个:
监视进程,如果出现QQ的进程就触发事件