我打开一个EXE文件后,怎么样在别一个进程里判断这个EXE的进程还在运行呢?
请指教
请指教
解决方案 »
- 请教一个简单的会议系统的开发
- 有两个类,而用同一个变量,如何根据情况,定义这个变量为A类变量或B类变量。
- For Each...Next 的用法
- 如何把声音文件加到窗口
- 请教如何屏蔽掉 rs.Source 的SQL语句
- 转载VB 6.0将在2008年“寿终正寝”
- 请详细说一说一进一出式语音卡是怎么回事可以吗?谢谢!
- 怎么在服务器端实现多个客户端同时能访问,不出现冲突
- 关于订单和销售单的转化,麻烦给个思路,谢谢!
- 请问如何在使TextBox控件只能输入数字或只能输入时间
- 请问使用VB写一个网页留言本(运行于IIS-(我的个人服务器))可行吗?
- 高手在那里,如何通过vb 查询网络中另一台机器的文件目录呢, 在线等,等待高手出现
Option ExplicitPrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const SW_SHOWNORMAL = 1
Const WM_CLOSE = &H10
Const gcClassnameMSWord = "OpusApp"
Const gcClassnameMSExcel = "XLMAIN"
Const gcClassnameMSIExplorer = "IEFrame"
Const gcClassnameMSVBasic = "wndclass_desked_gsk"
Const gcClassnameNotePad = "Notepad"
Const gcClassnameMyVBApp = "ThunderForm"
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
'Ask for a Window title
Ret = InputBox("Enter the exact window title:" + Chr$(13) + Chr$(10) + "Note: must be an exact match")
'Search the window
WinWnd = FindWindow(vbNullString, Ret)
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
'Show the window
ShowWindow WinWnd, SW_SHOWNORMAL
'Create a buffer
lpClassName = Space(256)
'retrieve the class name
RetVal = GetClassName(WinWnd, lpClassName, 256)
'Show the classname
MsgBox "Classname: " + Left$(lpClassName, RetVal)
'Post a message to the window to close itself
PostMessage WinWnd, WM_CLOSE, 0&, 0&
End Sub
比较一下是不是同一个文件就知道了
-----------------------------------------------------------------------------
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, ProcessID) '获取进程句柄
If hProcess <> 0 Then
lRet = EnumProcessModules(hProcess, Modules(1), 255, cbNeeded2)
If lRet <> 0 Then
ModuleName = Space(255)
nSize = 255
lRet = GetModuleFileNameExA(hProcess, Modules(1), ModuleName, 255)
'EXE文件路径、文件名
strPath = LCase(Left(ModuleName, InStr(1, ModuleName, Chr(0)) - 1))
'在这里比较是不是要判断的EXE文件 End If
End If
Call CloseHandle(hProcess)
http://sanjianxia.myrice.com/vb/113.htm