Like this for "PUREBASIC.EXE"
Code: Select all
Structure PROCESSENTRY32
dwSize.l
cntUsage.l
th32ProcessID.l
th32DefaultHeapID.l
th32ModuleID.l
cntThreads.l
th32ParentProcessID.l
pcPriClassBase.l
dwFlags.l
szExeFile.b[#MAX_PATH]
EndStructure
#TH32CS_SNAPPROCESS = $2
#PROCESS_ALL_ACCESS=$FFF
;-Procedure List
If OpenLibrary(0, "Kernel32.dll")
CreateToolhelpSnapshot = IsFunction(0, "CreateToolhelp32Snapshot")
ProcessFirst = IsFunction(0, "Process32First")
ProcessNext = IsFunction(0, "Process32Next")
If CreateToolhelpSnapshot And ProcessFirst And ProcessNext
Process.PROCESSENTRY32\dwSize = SizeOf(PROCESSENTRY32)
Snapshot = CallFunctionFast(CreateToolhelpSnapshot, #TH32CS_SNAPPROCESS, 0)
If Snapshot
ProcessFound = CallFunctionFast(ProcessFirst, Snapshot, Process)
While ProcessFound
If GetFilePart(PeekS(@Process\szExeFile)) ="PUREBASIC.EXE"
Check =PeekL(@Process\th32ProcessID)
Break
EndIf
ProcessFound = CallFunctionFast(ProcessNext, Snapshot, Process)
Wend
EndIf
CloseHandle_(Snapshot)
EndIf
CloseLibrary(0)
EndIf
Repeat
hwin=FindWindow_(0,0)
While hwin<>0 ;And oldwin <>win
MemID= AllocateMemory (255)
GetWindowText_ (hwin, MemID, 255)
title$ = PeekS (MemID)
GetWindowThreadProcessId_(hwin,@ProcessId.l)
If Check= ProcessId
Debug "ProcessID =: "+StrU(ProcessId,#Long)
; Debug title$
Break
EndIf
hwin=GetWindow_(hwin,#GW_HWNDNEXT)
Wend
Until hwin
Debug "WindHandler =: "+Str(hwin)

Best regards
Henrik