这个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






本文转载:CSDN博客