'Use the following for main window
lngThreadId = GetWindowThreadProcessId(hwnd, lngProcessId)
' then call function lngParnetPID = MyGetParentPID(lngProcessId)
'Add the following to Sub HoverIt1()
lngThreadID = GetWindowThreadProcessId(HwndOver, lngProcessID)
.lblHover1 = .lblHover1 & "Window Process ID: " & CStr(lngProcessID) & vbCrLf ' Display window process ID
.lblHover1 = .lblHover1 & "Window Thread ID: " & CStr(lngThreadID) & vbCrLf ' Display window thread ID
lngParentProcID = MyGetParentPID(lngProcessID)
.lblHover1 = .lblHover1 & "Parent Process ID:" & lngParentProcID & vbCrLf
'Create a new function (beware I have not removed unused variables yet)
Public Function MyGetParentPID(lpID As Long) As Long
Dim lSnapShotP As Long
Dim hProcess As Long
Dim lNextProcess As Long
Dim tPE As PROCESSENTRY32
Dim tME As MODULEENTRY32
Dim lvwListItem As ListItem
Dim ModuleName As String * MAX_PATH
Dim sModName As String
Dim sExe As String
Dim lRet As Long
MyGetParentPID = 9999
' Create snapshot
lSnapShotP = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
If lSnapShotP <> INVALID_HANDLE_VALUE Then
' Length of the structure
tPE.dwSize = Len(tPE)
' Find first process
lNextProcess = Process32First(lSnapShotP, tPE)
Do While lNextProcess
' must reset every cycle
sModName = ""
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, tPE.th32ProcessID)
'Get the module file name
lRet = GetModuleFileNameExA(hProcess, 0, ModuleName, MAX_PATH)
'Get the module file name out of the buffer, lRet is how
'many characters the string is, the rest of the buffer is spaces
sModName = RTrimNull$(ModuleName)
sExe = RTrimNull$(tPE.szExeFile)
sModName = ReplacePathSystem(sModName, sExe)
Call CloseHandle(hProcess)
' Found specified process
If lpID = tPE.th32ProcessID Then
MyGetParentPID = tPE.th32ParentProcessID
Exit Do
End If
' Get next process
lNextProcess = Process32Next(lSnapShotP, tPE)
Loop
Call CloseHandle(lSnapShotP)
End If
End Function