Page 1 of 1

[Windows] How to list Running Processes/Problem with Func

Posted: Thu Mar 15, 2018 6:59 pm
by 0x90
Hello guys, I'm having troubles following a code example I found at:
http://www.purebasic.fr/english/viewtopic.php?t=8086


Image

So the thing is that as you can see in the picture, it seems that the returned names are not correctly displayed in the ascii format... maybe non-utf?

I don't know, so I was hoping that I could get some help, this is the procedure that I need, but that's the only caveat, the names...

Re: [Windows] How to list Running Processes/Problem with Fun

Posted: Thu Mar 15, 2018 10:22 pm
by CELTIC88
Hi NOP = 0x90 :D

Welcome to PB Forum

Code: Select all

Macro DebugStringType(pStr)
  CompilerIf #PB_Compiler_Unicode 
    Debug PeekS(pStr)
  CompilerElse
    Debug PeekS(pStr,-1,#PB_Ascii)
  CompilerEndIf
EndMacro

snap = CreateToolhelp32Snapshot_(#TH32CS_SNAPPROCESS, 0)
If snap
  Proc32.PROCESSENTRY32\dwSize = SizeOf(PROCESSENTRY32)
  If Process32First_(snap, @Proc32)
    
    DebugStringType(@Proc32\szExeFile)
    
    While Process32Next_(snap, @Proc32)
      
      DebugStringType(@Proc32\szExeFile)
      
    Wend
  EndIf    
  CloseHandle_ (snap)
EndIf

Re: [Windows] How to list Running Processes/Problem with Fun

Posted: Fri Mar 22, 2019 7:58 pm
by Blue
Very good code, CELTIC88. Intelligent and simple. Just what the doctor ordered.
Thank you.

I'm trying to write code to close a bunch of windowed apps I open as small separate processes.
Some other code offered on the forum shows how, but its process listing fails to list names that include spaces.
Yours does this perfectly.

Now if I could just combine those two, i'd be a happy camper again.