Rainbow » 13.05.2003 (Вт) 15:34
Путь к приложению можно узнать так:
Private Type MODULEENTRY32
dwSize As Long ' size, in bytes, of structure
th32ModuleID As Long
th32ProcessID As Long
GlblcntUsage As Long
ProccntUsage As Long
modBaseAddr As Long
modBaseSize As Long
hModule As Long
szModule As String * MAX_MODULE_NAME32
szExePath As String * 260 ' MAX_PATH
End Type
Private Declare Function apiCreateToolhelp32Snapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
Private Declare Function Module32First Lib "kernel32" (ByVal hSnapshot As Long, ModEntry As MODULEENTRY32) As Boolean
Private Declare Function Module32Next Lib "kernel32" (ByVal hSnapshot As Long, ModEntry As MODULEENTRY32) As Boolean
Private Const TH32CS_SNAPMODULE = &H8
Public Function ShowFilePath(ByVal lhWnd As Long, ByVal lParam As Long) As Long
Dim nSnapshot As Long
Dim uModule As MODULEENTRY32
Dim nPosition As Long
Dim nProcessID
GetWindowThreadProcessId lhWnd, nProcessID
uModule.dwSize = Len(uModule)
nSnapshot = apiCreateToolhelp32Snapshot(TH32CS_SNAPMODULE, nProcessID)
Module32First nSnapshot, uModule
nPosition = InStr(1, uModule.szExePath, Chr$(0), vbBinaryCompare)
If nPosition > 0 Then
MsgBox Left$(uModule.szExePath, nPosition - 1)
End If
ShowFilePath = True
End Function