🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #13461

Win32API - Path van draaiende EXE's zien in Win2k ?

#13461
From: BuiZe
Date: Sat, 14 Jul 2001 07:31
74 lines
3062 bytes
Met onderstaande code enum ik de EXE-name van alle lopende programma's.
In Win9x krijg ik dan volledig path + filename te zien, bijvoorbeeld :
c:\windows\explorer.exe

In Windows 2000 echter krijg ik enkel de EXE-name te zien:
explorer.exe

Is er *een* manier om toch het path te zien van die EXE's ?

Dank bij voorbaat,

BuiZe


'----------------------------------------------

Const MAX_PATH& = 260

Type PROCESSENTRY32
    dwSize As Long
    cntUsage As Long
    th32ProcessID As Long
    th32DefaultHeapID As Long
    th32ModuleID As Long
    cntThreads As Long
    th32ParentProcessID As Long
    pcPriClassBase As Long
    dwFlags As Long
    szexeFile As String * MAX_PATH
End Type

Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias
"CreateToolhelp32Snapshot" (ByVal lFlags As Long, lProcessID As Long) As
Long

Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal
hSnapshot As Long, uProcess As PROCESSENTRY32) As Long

Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal
hSnapshot As Long, uProcess As PROCESSENTRY32) As Long

'----------------------------------------------

Sub EnumPrograms()

    Dim uProcess As PROCESSENTRY32
    Dim rProcessFound As Long
    Dim hSnapshot As Long
    Dim szExename As String
    Dim i As Integer

    Const TH32CS_SNAPPROCESS As Long = 2&

    uProcess.dwSize = Len(uProcess)

    hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)

    rProcessFound = ProcessFirst(hSnapshot, uProcess)

    Do While rProcessFound
        i = InStr(1, uProcess.szexeFile, Chr(0))
        szExename = LCase$(Left$(uProcess.szexeFile, i - 1))
        List1.AddItem (szExename)
        rProcessFound = ProcessNext(hSnapshot, uProcess)
    Loop

    Call CloseHandle(hSnapshot)


End Sub

'----------------------------------------------
Technical Details
Message-ID: <lzS37.6808$Xy1.1294140@afrodite.telenet-ops.be>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!newsfeeds.belnet.be!news.belnet.be!afrodite.telenet-ops.be!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 107324,25c10eea564a11e5,start
X-Google-Attributes: gid107324,public
X-Google-Thread: fcea4,25c10eea564a11e5,start
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2001-07-14 00:31:30 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!newsfeeds.belnet.be!news.belnet.be!afrodite.telenet-ops.be!not-for-mail
From: "BuiZe" <news@buize.cjb.net>
Newsgroups: be.comp.programming,nl.comp.programmeren
Subject: Win32API - Path van draaiende EXE's zien in Win2k ?
Lines: 76
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6700
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700
Message-ID: <lzS37.6808$Xy1.1294140@afrodite.telenet-ops.be>
Date: Sat, 14 Jul 2001 07:31:29 GMT
NNTP-Posting-Host: 213.224.107.236
X-Complaints-To: abuse@pandora.be
X-Trace: afrodite.telenet-ops.be 995095889 213.224.107.236 (Sat, 14 Jul 2001 09:31:29 MET DST)
NNTP-Posting-Date: Sat, 14 Jul 2001 09:31:29 MET DST
Organization: Telenet Internet