hActiveWnd = GetForegroundWindow
StrangerTreadID = GetWindowThreadProcessId(hActiveWnd, 0)
lRet = OpenProcess(PROCESS_VM_READ Or PROCESS_QUERY_INFORMATION, 0, StrangerTreadID)
Debug.Print "Err.Description = "; GetErrorString(Err.LastDllError)
StrangerTreadID = GetWindowThreadProcessId(hActiveWnd, ProcessID)
lRet = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessID)
'Debug.Print "Err.Description = "; GetErrorString(Err.LastDllError)
If lRet > 0 Then
sTemp = Space(MAX_PATH)
GetModuleFileName lRet, sTemp, Len(sTemp)
Public Function getForegroundHwndPathName() As String
Dim cbNeeded As Long
Dim Modules(1 To 200) As Long
Dim nSize As Long
Dim lRet As Long
Dim ModuleName As String
Dim hProcess As Long
Dim hwnd As Long, tid As Long, pid As Long
hwnd = GetForegroundWindow
tid = GetWindowThreadProcessId(hwnd, pid)
If pid = 0 Then getForegroundHwndPathName = "[System Idle Process]": Exit Function
If pid = 4 Then getForegroundHwndPathName = "[System]": Exit Function
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, pid)
If hProcess <> 0 Then
lRet = EnumProcessModules(hProcess, Modules(1), 200, cbNeeded)
If lRet <> 0 Then
ModuleName = Space(MAX_PATH)
nSize = MAX_PATH
lRet = GetModuleFileNameExA(hProcess, Modules(1), ModuleName, nSize)
If CBool(InStr(1, (Left(ModuleName, lRet)), "", vbTextCompare)) Then
getForegroundHwndPathName = Left(ModuleName, lRet)
End If
End If
End If
CloseHandle hProcess
End Function
The module must have been loaded by the current process.
lRet = EnumProcessModules(hProcess, Modules(1), 200, cbNeeded)
If CBool(InStr(1, (Left(ModuleName, lRet)), "", vbTextCompare)) Then
Left(ModuleName, lRet)
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 25