Dim uSnapShot As Long '系统快照返回值
Dim uResult As Long '遍历进程返回值
Dim uProcess As PROCESSENTRY32 '定义进程结构变量
Dim meHandle As Long '进程句柄
uSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&) '建立系统快照
uProcess.dwSize = Len(uProcess) '初始化进程信息长度
If uSnapShot Then
uResult = Process32First(uSnapShot, uProcess) '取得第一个进程
Do While uResult
If InStr(Left(uProcess.szexeFile, InStr(uProcess.szexeFile, Chr(0)) - 1), "QQ.exe") 0 Then
meHandle = OpenProcess(PROCESS_ALL_ACCESS, True, uProcess.th32ProcessID)
'meHandle中就是你想要的QQ的句柄
End If
uResult = Process32Next(uSnapShot, uProcess) '取得快照中的下一个进程
Loop
End If