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

Just starting out? Need help? Post your questions and find answers here.
0x90
New User
New User
Posts: 2
Joined: Thu Mar 15, 2018 6:18 pm

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

Post 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...
User avatar
CELTIC88
Enthusiast
Enthusiast
Posts: 154
Joined: Thu Sep 17, 2015 3:39 pm

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

Post 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
interested in Cybersecurity..
User avatar
Blue
Addict
Addict
Posts: 884
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

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

Post 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.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
Post Reply