Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tasklist
#10
(08-09-2024, 08:53 PM)BDS107 Wrote: With the help of ChatGPT, I get this. But, I got an error on line 3: Illegal SUB/FUNCTION parameter. Help...


Code: (Select All)
DECLARE DYNAMIC LIBRARY "kernel32"
    FUNCTION CreateToolhelp32Snapshot% (BYVAL dwFlags AS _UNSIGNED LONG, BYVAL th32ProcessID AS _UNSIGNED LONG)
    FUNCTION Process32First% (BYVAL hSnapshot AS _UNSIGNED LONG, lppe AS ANY)    '*** Error in this line
    FUNCTION Process32Next% (BYVAL hSnapshot AS _UNSIGNED LONG, lppe AS ANY)
    FUNCTION CloseHandle% (BYVAL hObject AS _UNSIGNED LONG)
END DECLARE


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 * 260
END TYPE


FUNCTION GetProcessList$ ()
    DIM processSnapshot AS _UNSIGNED LONG
    DIM processEntry AS PROCESSENTRY32
    DIM processList AS STRING

    processEntry.dwSize = LEN(processEntry)

    ' Maak een snapshot van alle draaiende processen
    processSnapshot = CreateToolhelp32Snapshot(2, 0)
    IF processSnapshot = -1 THEN
        GetProcessList$ = "Fout bij het maken van snapshot."
        EXIT FUNCTION
    END IF

    ' Verkrijg het eerste proces
    IF Process32First(processSnapshot, processEntry) = 0 THEN
        GetProcessList$ = "Geen draaiende processen gevonden."
        EXIT FUNCTION
    END IF

    ' Voeg elk proces toe aan de lijst
    DO
        processList = processList + LEFT$(processEntry.szExeFile, INSTR(processEntry.szExeFile, CHR$(0)) - 1) + _NEWLINE$
    LOOP UNTIL Process32Next(processSnapshot, processEntry) = 0

    ' Sluit het snapshot
    CloseHandle processSnapshot

    GetProcessList$ = processList
END FUNCTION


PRINT GetProcessList$
There is no "ANY" type identifier in QB64.

Look at the documentation for the functions and see what the return is. my guess would be if it's numeric use AS _UNSIGNED LONG or AS DOUBLE.

Update:

Here is one of them: https://learn.microsoft.com/en-us/window...ess32first

but it says it needs a return of LPPROCESSENTRY32 which has its structure defined in a link on the page.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
Tasklist - by BDS107 - 08-08-2024, 01:59 PM
RE: Tasklist - by SpriggsySpriggs - 08-08-2024, 02:08 PM
RE: Tasklist - by Steffan-68 - 08-08-2024, 04:07 PM
RE: Tasklist - by SMcNeill - 08-08-2024, 02:34 PM
RE: Tasklist - by Pete - 08-08-2024, 03:31 PM
RE: Tasklist - by Pete - 08-08-2024, 04:13 PM
RE: Tasklist - by DSMan195276 - 08-08-2024, 04:17 PM
RE: Tasklist - by BDS107 - 08-09-2024, 09:57 AM
RE: Tasklist - by BDS107 - 08-09-2024, 08:53 PM
RE: Tasklist - by TerryRitchie - 08-09-2024, 09:44 PM
RE: Tasklist - by SMcNeill - 08-10-2024, 03:06 AM
RE: Tasklist - by Pete - 08-10-2024, 03:23 AM



Users browsing this thread: 2 Guest(s)