Seite 2 von 2

Verfasst: 23.03.2007 16:10
von ts-soft
Hier mal in Kurzfassung :mrgreen:

Code: Alles auswählen

Procedure SearchProcess(Name.s)
  Protected result.l, Snapshot.l, ProcessFound.l, PN$, Process.PROCESSENTRY32
  Process\dwSize = SizeOf(PROCESSENTRY32)
  Snapshot = CreateToolhelp32Snapshot_(#TH32CS_SNAPPROCESS, 0)
  If Snapshot
    ProcessFound = Process32First_(Snapshot, Process)
    While ProcessFound
      PN$ = UCase(PeekS(@Process\szExeFile, #PB_Any, #PB_Ascii))
      If UCase(Name) = GetFilePart(PN$) : result = #True : Break : EndIf
      ProcessFound = Process32Next_(Snapshot, Process)
    Wend
    CloseHandle_(Snapshot)
  EndIf
  ProcedureReturn result
EndProcedure

If SearchProcess("PureBasic.exe")
  Debug "Programm läuft"
Else
  Debug "Nicht gefunden"
EndIf
Und schneller (siehe Break)

Nachtrag:
Unterstützt jetzt auch Unicode!