一 cmd命令
1 查看占用端口的进程ID
#netstat -aon | findstr "10010"
2 查看进程ID的进程名称
#tasklist | findstr "2044"
二 执行cmd命令的windows函数
- system
#include <stdlib.h>
int system(char *command);
- _popen
create pipes and excute command
FILE *_popen(
const char *command,
const char *mode
);
// crt_popen.c
/* This program uses _popen and _pclose to receive a
* stream of text from a system process.
*/
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
char psBuffer[128];
FILE *pPipe;
/* Run DIR so that it writes its output to a pipe. Open this
* pipe with read text attribute so that we can read it
* like a text file.
*/
if( (pPipe