Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetModuleFileNameExA Lib "psapi.dll" (ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFilename As String, ByVal nSize As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Function GetPath(ByVal hwnd As Long) As String
Dim PID As Long, hPss As Long
Dim FileName As String * 1024
Call GetWindowThreadProcessId(hwnd, PID)
hPss = OpenProcess(&HF0000 Or &H100000 Or &HFFF, False, PID)
Call GetModuleFileNameExA(hPss, 0, FileName, 1024)
GetPath = Trim(FileName)
CloseHandle hPss
End Function
Private Sub Command1_Click()
MsgBox GetPath(Val())
End Sub
单击 按钮后 出现? 怎么回事呢?
我想点击按钮后 把取到的 句柄发送到Text1