08-09-2024, 09:44 PM
(This post was last modified: 08-09-2024, 09:47 PM by TerryRitchie.)
(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...There is no "ANY" type identifier in QB64.
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$
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.