Posts: 37
Threads: 12
Joined: Jun 2022
Reputation:
6
Can you request a list in QB64 like the DOS command TASKLIST?
You can of course use a SHELL and save the result temporarily on disk. But that is too slow if you want to update constantly. So, I don't want this.
Posts: 733
Threads: 30
Joined: Apr 2022
Reputation:
43
You can use pipecom to accomplish this. I don't know where my latest code for it is. But it would work for what you're asking.
Tread on those who tread on you
Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
Shell with a redirect to clipboard might work as well, and then just read _ClipBoard$.
Posts: 2,171
Threads: 222
Joined: Apr 2022
Reputation:
103
08-08-2024, 03:31 PM
(This post was last modified: 08-08-2024, 03:32 PM by Pete.)
@SpriggsySpriggs
I think the pipecom version I downloaded was the one you updated in Aug of 2021 at: https://qb64forum.alephc.xyz/index.php?t...#msg134943
Pete
Shoot first and shoot people who ask questions, later.
Posts: 73
Threads: 3
Joined: Apr 2022
Reputation:
14
(08-08-2024, 02:08 PM)SpriggsySpriggs Wrote: You can use pipecom to accomplish this. I don't know where my latest code for it is. But it would work for what you're asking.
Could it be that you are looking for this article?
https://qb64phoenix.com/forum/showthread...ht=pipecom
Posts: 2,171
Threads: 222
Joined: Apr 2022
Reputation:
103
08-08-2024, 04:13 PM
(This post was last modified: 08-08-2024, 04:14 PM by Pete.)
@Steffan-68
I was comparing that one to the one I downloaded...
2021 version:
Code: (Select All)
$If PIPECOM = UNDEFINED Then
$Let PIPECOM = TRUE
Function pipecom& (cmd As String, stdout As String, stderr As String)
stdout = "": stderr = ""
$If WIN Then
Type SECURITY_ATTRIBUTES
As _Unsigned Long nLength
$If 64BIT Then
As String * 4 padding
$End If
As _Offset lpSecurityDescriptor
As Long bInheritHandle
$If 64BIT Then
As String * 4 padding2
$End If
End Type
Type STARTUPINFO
As Long cb
$If 64BIT Then
As String * 4 padding
$End If
As _Offset lpReserved, lpDesktop, lpTitle
As _Unsigned Long dwX, dwY, dwXSize, dwYSize, dwXCountChars, dwYCountChars, dwFillAttribute, dwFlags
As _Unsigned Integer wShowWindow, cbReserved2
$If 64BIT Then
As String * 4 padding2
$End If
As _Offset lpReserved2, hStdInput, hStdOutput, hStdError
End Type
Type PROCESS_INFORMATION
As _Offset hProcess, hThread
As _Unsigned Long dwProcessId
$If 64BIT Then
As String * 4 padding
$End If
End Type
Const STARTF_USESTDHANDLES = &H00000100
Const CREATE_NO_WINDOW = &H8000000
Const INFINITE = 4294967295
Const WAIT_FAILED = &HFFFFFFFF
Declare CustomType Library
Function CreatePipe& (ByVal hReadPipe As _Offset, Byval hWritePipe As _Offset, Byval lpPipeAttributes As _Offset, Byval nSize As _Unsigned Long)
Function CreateProcess& (ByVal lpApplicationName As _Offset, Byval lpCommandLine As _Offset, Byval lpProcessAttributes As _Offset, Byval lpThreadAttributes As _Offset, Byval bInheritHandles As Long, Byval dwCreationFlags As _Unsigned Long, Byval lpEnvironment As _Offset, Byval lpCurrentDirectory As _Offset, Byval lpStartupInfo As _Offset, Byval lpProcessInformation As _Offset)
Function GetExitCodeProcess& (ByVal hProcess As _Offset, Byval lpExitCode As _Offset)
Sub HandleClose Alias "CloseHandle" (ByVal hObject As _Offset)
Function ReadFile& (ByVal hFile As _Offset, Byval lpBuffer As _Offset, Byval nNumberOfBytesToRead As _Unsigned Long, Byval lpNumberOfBytesRead As _Offset, Byval lpOverlapped As _Offset)
Function WaitForSingleObject~& (ByVal hHandle As _Offset, Byval dwMilliseconds As _Unsigned Long)
End Declare
Dim As Long ok: ok = 1
Dim As _Offset hStdOutPipeRead, hStdOutPipeWrite, hStdReadPipeError, hStdOutPipeError
Dim As SECURITY_ATTRIBUTES sa: sa.nLength = Len(sa): sa.lpSecurityDescriptor = 0: sa.bInheritHandle = 1
If CreatePipe(_Offset(hStdOutPipeRead), _Offset(hStdOutPipeWrite), _Offset(sa), 0) = 0 Then
pipecom = -1
Exit Function
End If
If CreatePipe(_Offset(hStdReadPipeError), _Offset(hStdOutPipeError), _Offset(sa), 0) = 0 Then
pipecom = -1
Exit Function
End If
Dim As STARTUPINFO si
si.cb = Len(si)
si.dwFlags = STARTF_USESTDHANDLES
si.hStdError = hStdOutPipeError
si.hStdOutput = hStdOutPipeWrite
si.hStdInput = 0
Dim As PROCESS_INFORMATION procinfo
Dim As _Offset lpApplicationName
Dim As String lpCommandLine: lpCommandLine = "cmd /c " + cmd + Chr$(0)
Dim As _Offset lpProcessAttributes, lpThreadAttributes
Dim As Long bInheritHandles: bInheritHandles = 1
Dim As _Unsigned Long dwCreationFlags: dwCreationFlags = CREATE_NO_WINDOW
Dim As _Offset lpEnvironment, lpCurrentDirectory
ok = CreateProcess(lpApplicationName, _Offset(lpCommandLine), lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, _Offset(si), _Offset(procinfo))
If ok = 0 Then
pipecom = -1
Exit Function
End If
HandleClose hStdOutPipeWrite
HandleClose hStdOutPipeError
Dim As String buf: buf = Space$(4096 + 1)
Dim As _Unsigned Long dwRead
While ReadFile(hStdOutPipeRead, _Offset(buf), 4096, _Offset(dwRead), 0) <> 0 And dwRead > 0
buf = Mid$(buf, 1, dwRead)
GoSub RemoveChr13
stdout = stdout + buf
buf = Space$(4096 + 1)
Wend
While ReadFile(hStdReadPipeError, _Offset(buf), 4096, _Offset(dwRead), 0) <> 0 And dwRead > 0
buf = Mid$(buf, 1, dwRead)
GoSub RemoveChr13
stderr = stderr + buf
buf = Space$(4096 + 1)
Wend
Dim As Long exit_code, ex_stat
If WaitForSingleObject(procinfo.hProcess, INFINITE) <> WAIT_FAILED Then
If GetExitCodeProcess(procinfo.hProcess, _Offset(exit_code)) Then
ex_stat = 1
End If
End If
HandleClose hStdOutPipeRead
HandleClose hStdReadPipeError
If ex_stat = 1 Then
pipecom = exit_code
Else
pipecom = -1
End If
Exit Function
RemoveChr13:
Dim As Long j
j = InStr(buf, Chr$(13))
Do While j
buf = Left$(buf, j - 1) + Mid$(buf, j + 1)
j = InStr(buf, Chr$(13))
Loop
Return
$Else
Declare CustomType Library
Function popen%& (cmd As String, readtype As String)
Function feof& (ByVal stream As _Offset)
Function fgets$ (str As String, Byval n As Long, Byval stream As _Offset)
Function pclose& (ByVal stream As _Offset)
End Declare
Declare Library
Function WEXITSTATUS& (ByVal stat_val As Long)
End Declare
Dim As _Offset stream
Dim buffer As String * 4096
If _FileExists("pipestderr") Then
Kill "pipestderr"
End If
stream = popen(cmd + " 2>pipestderr", "r")
If stream Then
While feof(stream) = 0
If fgets(buffer, 4096, stream) <> "" And feof(stream) = 0 Then
stdout = stdout + Mid$(buffer, 1, InStr(buffer, Chr$(0)) - 1)
End If
Wend
Dim As Long status, exit_code
status = pclose(stream)
exit_code = WEXITSTATUS(status)
If _FileExists("pipestderr") Then
Dim As Integer errfile
errfile = FreeFile
Open "pipestderr" For Binary As #errfile
If LOF(errfile) > 0 Then
stderr = Space$(LOF(errfile))
Get #errfile, , stderr
End If
Close #errfile
Kill "pipestderr"
End If
pipecom = exit_code
Else
pipecom = -1
End If
$End If
End Function
Function pipecom_lite$ (cmd As String)
Dim As Long a
Dim As String stdout, stderr
a = pipecom(cmd, stdout, stderr)
If stderr <> "" Then
pipecom_lite = stderr
Else
pipecom_lite = stdout
End If
End Function
$End If
And the one in the thread you mentioned from 2023. Oh, I substituted in Spriggsys while from Steve's post:
Code: (Select All)
Common Shared winver%, utente$
Common Shared ip4$
Dim ver As String
ver = Mid$(pipecom_lite("ver"), 2)
Print pipecom_lite("ver")
Sleep
k$ = ""
For f = 1 To Len(ver)
If InStr("1234567890.", Mid$(ver, f, 1)) <> 0 Then k$ = k$ + Mid$(ver, f, 1)
Next f
If InStr(k$, "6.1.76") > 0 Then
winver = 7
ElseIf InStr(k$, "6.2.") > 0 Or InStr(k$, "6.3.") > 0 Then
winver = 8
ElseIf InStr(k$, "10.") > 0 Then
winver = 10
End If
If winver = 10 Then
For f = InStr(_Dir$(""), "User") To Len(_Dir$(""))
If Mid$(_Dir$(""), f, 1) = "\" Then Exit For
Next f
utente$ = Mid$(_Dir$(""), f + 1, InStr(Mid$(_Dir$(""), f + 1), "\") - 1)
ElseIf winver = 7 Then
For f = InStr(_Dir$(""), "User") To Len(_Dir$(""))
If Mid$(_Dir$(""), f, 1) = "\" Then Exit For
Next f
utente$ = Mid$(_Dir$(""), f + 1, InStr(Mid$(_Dir$(""), f + 1), "\") - 1)
End If
End
'-----------------------------------------------------------------------------------------------------------------------------
'6.0.6000 Windows Vista
'6.0.6001 Windows Vista with Service Pack 1 'or Windows Server 2008
'6.1.7600 Windows 7 'or Windows Server 2008 R2
'6.1.7601 Windows 7 with Service Pack 1 'or Windows Server 2008 R2 with Service Pack 1
'6.2.9200 Windows 8 'or Windows Server 2012
'6.3.9200 Windows 8.1 'or Windows Server 2012 R2
'6.3.9600 Windows 8.1 with Update 1
'10.0.10240 Windows 10 Version 1507
'10.0.10586 Windows 10 Version 1511 (November Update)
'10.0.14393 Windows 10 Version 1607 (Anniversary Update) 'or Windows Server 2016
'10.0.15063 Windows 10 Version 1703 (Creators Update)
'10.0.16299 Windows 10 Version 1709 (Fall Creators Update)
'10.0.17134 Windows 10 Version 1803 (April 2018 Update)
'10.0.17763 Windows 10 Version 1809 (October 2018 Update) 'or Windows Server 2019
'10.0.18362 Windows 10 Version 1903 (May 2019 Update)
'10.0.18363 Windows 10 Version 1909 (November 2019 Update)
'10.0.19041 Windows 10 Version 2004 (May 2020 Update)
'Note that there is normally no need to specify the build numbers (i.e., you may simply use "6.2" for Windows 8).
'-----------------------------------------------------------------------------------------------------------------------------
$If PIPECOM = UNDEFINED Then
$Let PIPECOM = TRUE
Function pipecom& (cmd As String, stdout As String, stderr As String)
stdout = "": stderr = ""
$If WIN Then
Type SECURITY_ATTRIBUTES
As _Unsigned Long nLength
$If 64BIT Then
As String * 4 padding
$End If
As _Offset lpSecurityDescriptor
As Long bInheritHandle
$If 64BIT Then
As String * 4 padding2
$End If
End Type
Type STARTUPINFO
As Long cb
$If 64BIT Then
As String * 4 padding
$End If
As _Offset lpReserved, lpDesktop, lpTitle
As _Unsigned Long dwX, dwY, dwXSize, dwYSize, dwXCountChars, dwYCountChars, dwFillAttribute, dwFlags
As _Unsigned Integer wShowWindow, cbReserved2
$If 64BIT Then
As String * 4 padding2
$End If
As _Offset lpReserved2, hStdInput, hStdOutput, hStdError
End Type
Type PROCESS_INFORMATION
As _Offset hProcess, hThread
As _Unsigned Long dwProcessId
$If 64BIT Then
As String * 4 padding
$End If
End Type
Const STARTF_USESTDHANDLES = &H00000100
Const CREATE_NO_WINDOW = &H8000000
Const INFINITE = 4294967295
Const WAIT_FAILED = &HFFFFFFFF
Declare CustomType Library
Function CreatePipe& (ByVal hReadPipe As _Offset, Byval hWritePipe As _Offset, Byval lpPipeAttributes As _Offset, Byval nSize As _Unsigned Long)
Function CreateProcess& (ByVal lpApplicationName As _Offset, Byval lpCommandLine As _Offset, Byval lpProcessAttributes As _Offset, Byval lpThreadAttributes As _Offset, Byval bInheritHandles As Long, Byval dwCreationFlags As _Unsigned Long, Byval lpEnvironment As _Offset, Byval lpCurrentDirectory As _Offset, Byval lpStartupInfo As _Offset, Byval lpProcessInformation As _Offset)
Function GetExitCodeProcess& (ByVal hProcess As _Offset, Byval lpExitCode As _Offset)
Sub HandleClose Alias "CloseHandle" (ByVal hObject As _Offset)
Function ReadFile& (ByVal hFile As _Offset, Byval lpBuffer As _Offset, Byval nNumberOfBytesToRead As _Unsigned Long, Byval lpNumberOfBytesRead As _Offset, Byval lpOverlapped As _Offset)
Function WaitForSingleObject~& (ByVal hHandle As _Offset, Byval dwMilliseconds As _Unsigned Long)
End Declare
Dim As Long ok: ok = 1
Dim As _Offset hStdOutPipeRead, hStdOutPipeWrite, hStdReadPipeError, hStdOutPipeError
Dim As SECURITY_ATTRIBUTES sa: sa.nLength = Len(sa): sa.lpSecurityDescriptor = 0: sa.bInheritHandle = 1
If CreatePipe(_Offset(hStdOutPipeRead), _Offset(hStdOutPipeWrite), _Offset(sa), 0) = 0 Then
pipecom = -1
Exit Function
End If
If CreatePipe(_Offset(hStdReadPipeError), _Offset(hStdOutPipeError), _Offset(sa), 0) = 0 Then
pipecom = -1
Exit Function
End If
Dim si As STARTUPINFO
si.cb = Len(si)
si.dwFlags = STARTF_USESTDHANDLES
si.hStdError = hStdOutPipeError
si.hStdOutput = hStdOutPipeWrite
si.hStdInput = 0
Dim As PROCESS_INFORMATION procinfo
Dim As _Offset lpApplicationName
Dim As String lpCommandLine: lpCommandLine = "cmd /c " + cmd + Chr$(0)
Dim As _Offset lpProcessAttributes, lpThreadAttributes
Dim As Long bInheritHandles: bInheritHandles = 1
Dim As _Unsigned Long dwCreationFlags: dwCreationFlags = CREATE_NO_WINDOW
Dim As _Offset lpEnvironment, lpCurrentDirectory
ok = CreateProcess(lpApplicationName, _Offset(lpCommandLine), lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, _Offset(si), _Offset(procinfo))
If ok = 0 Then
pipecom = -1
Exit Function
End If
HandleClose hStdOutPipeWrite
HandleClose hStdOutPipeError
Dim As String buf: buf = Space$(4096 + 1)
Dim As _Unsigned Long dwRead
While 1
'While ReadFile(hStdOutPipeRead, _Offset(buf), 4096, _Offset(dwRead), 0) <> 0 And dwRead > 0
x = ReadFile(hStdOutPipeRead, _Offset(buf), 4096, _Offset(dwRead), 0)
If x <> 0 And dwRead > 0 Then
buf = Mid$(buf, 1, dwRead)
GoSub RemoveChr13
stdout = stdout + buf
buf = Space$(4096 + 1)
Else
Exit While
End If
Wend
While ReadFile(hStdOutPipeRead, _Offset(buf), 4096, _Offset(dwRead), 0) <> 0
If dwRead > 0 Then
buf = Mid$(buf, 1, dwRead)
GoSub RemoveChr13
stdout = stdout + buf
buf = Space$(4096 + 1)
End If
Wend
While ReadFile(hStdReadPipeError, _Offset(buf), 4096, _Offset(dwRead), 0) <> 0
If dwRead > 0 Then
buf = Mid$(buf, 1, dwRead)
GoSub RemoveChr13
stderr = stderr + buf
buf = Space$(4096 + 1)
End If
Wend
Dim As Long exit_code, ex_stat
If WaitForSingleObject(procinfo.hProcess, INFINITE) <> WAIT_FAILED Then
If GetExitCodeProcess(procinfo.hProcess, _Offset(exit_code)) Then
ex_stat = 1
End If
End If
HandleClose hStdOutPipeRead
HandleClose hStdReadPipeError
If ex_stat = 1 Then
pipecom = exit_code
Else
pipecom = -1
End If
Exit Function
RemoveChr13:
Dim As Long j
j = InStr(buf, Chr$(13))
Do While j
buf = Left$(buf, j - 1) + Mid$(buf, j + 1)
j = InStr(buf, Chr$(13))
Loop
Return
$Else
Declare CustomType Library
Function popen%& (cmd As String, readtype As String)
Function feof& (ByVal stream As _Offset)
Function fgets$ (str As String, Byval n As Long, Byval stream As _Offset)
Function pclose& (ByVal stream As _Offset)
End Declare
Declare Library
Function WEXITSTATUS& (ByVal stat_val As Long)
End Declare
Dim As _Offset stream
Dim buffer As String * 4096
If _FileExists("pipestderr") Then
Kill "pipestderr"
End If
stream = popen(cmd + " 2>pipestderr", "r")
If stream Then
While feof(stream) = 0
If fgets(buffer, 4096, stream) <> "" And feof(stream) = 0 Then
stdout = stdout + Mid$(buffer, 1, InStr(buffer, Chr$(0)) - 1)
End If
Wend
Dim As Long status, exit_code
status = pclose(stream)
exit_code = WEXITSTATUS(status)
If _FileExists("pipestderr") Then
Dim As Integer errfile
errfile=FREEFILE
Open "pipestderr" For Binary As #errfile
If LOF(errfile) > 0 Then
stderr = Space$(LOF(errfile))
Get #errfile, , stderr
End If
Close #errfile
Kill "pipestderr"
End If
pipecom = exit_code
Else
pipecom = -1
End If
$End If
End Function
Function pipecom_lite$ (cmd As String)
Dim As Long a
Dim As String stdout, stderr
a = pipecom(cmd, stdout, stderr)
If stderr <> "" Then
pipecom_lite = stderr
Else
pipecom_lite = stdout
End If
End Function
$End If
That seems to be more updated than my saved copy. + 1 for the find!
Pete
Shoot first and shoot people who ask questions, later.
Posts: 303
Threads: 10
Joined: Apr 2022
Reputation:
44
(08-08-2024, 01:59 PM)BDS107 Wrote: Can you request a list in QB64 like the DOS command TASKLIST?
You can of course use a SHELL and save the result temporarily on disk. But that is too slow if you want to update constantly. So, I don't want this. There's nothing built-in for this so you'll have to use OS-specific APIs for it.
On Windows, you can use `EnumProcesses` and then `OpenProcess` to get the list of all Process IDs and information about each. You can call these and the other associated APIs via `Declare Library`.
On Linux /proc is the actual API, so you should be able to do it all from QB64 code (no Declare Library necessary). Use `_FILES$` to iterate the contents of `/proc` to get all the process IDs (each process ID is a folder name). Then use `OPEN` to read the various files in each process directory to get information on each process. The docs for what files are there and what they contain is here.
On Mac OS I'm not totally sure. Google suggests there is a `libproc` library you can use, which you would then call via `Declare Library`. It seems more limited in terms of what you can read compared to Windows and Linux though.
Posts: 37
Threads: 12
Joined: Jun 2022
Reputation:
6
(08-08-2024, 04:17 PM)DSMan195276 Wrote: On Windows, you can use `EnumProcesses` and then `OpenProcess` to get the list of all Process IDs and information about each. You can call these and the other associated APIs via `Declare Library
Can you give more info on those Windows "EnumProcesses" and "OpenProcess" calls? How to call them from QB64?
Posts: 37
Threads: 12
Joined: Jun 2022
Reputation:
6
08-09-2024, 08:53 PM
(This post was last modified: 08-09-2024, 08:53 PM by BDS107.)
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$
Posts: 1,272
Threads: 119
Joined: Apr 2022
Reputation:
100
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...
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
|