Need a list of all windows processes? Or need the PID of a specific process, but you've only got a name?
This repository shows the main parts needed to get a process list:
- Create a snapshot of the current windows process list using
CreateToolhelp32Snapshot
. - Fetch the first process in the snapshot list with
Process32First
. - Keep iterating with
Process32Next
, until you get theERROR_NO_MORE_FILES
error, which is your cue to finish.
go get github.com/denisbrodbeck/how2readwindowsprocesses
On Windows you can build it directly with go build main.go
.
On Linux/OSX you need to target the correct environment:
GOOS=windows GOARCH=amd64 go build -o bin/processes.exe main.go
# or
GOOS=windows GOARCH=386 go build -o bin/processes.exe main.go
If you are missing dependencies, you can install them with dep:
cd "$GOPATH/src/github.com/denisbrodbeck/how2readwindowsprocesses"
dep init
See MSDN doc for way more info on this subject. Thanks go to fluter's hints and xian's answer on SO.
The Unlicense. Please have a look at the LICENSE.md for more details.