这个Windows呢, 有点恼人, 想打印个进程号, 要查半天, 哎, 还是把你查到了。 unix/linux多好啊, 特别擅长于什么进程线程这玩意儿。
不多说, 遇一个, 学一个:
- #include <stdio.h> // for printf
- #include <stdlib.h> // for system
- #include <windows.h> // for GetCurrentProcessId
-
- int main()
- {
- printf("%ld\n", GetCurrentProcessId());
- system("tasklist | findstr test.exe");
-
- return 0;
- }
结果:
5756
test.exe 5756 Console 0 1,144 K

![[手游] 三网H5小游戏【少年仙路】WIN系服务端+Linux手工服务端+详细搭建教程](https://cdn.jxasp.com:9143/image/20260615/136BC33AA47EB0D84E878835A8B38FDB.png)

















