在windows下如何实现重定向

来源:百度知道 编辑:UC知道 时间:2024/05/12 02:14:15
我主要想实现一个能调用本机ip,子网掩码,默认网关,和dns的方法,我想用ipconfig来将输出的东西重定向到一个文件中,在调用这个文件,如果有其他方法,也可以告诉我,详细一点,成功后给分

#include <Windows.h>
#include <stdio.h>

void main()
{
SECURITY_ATTRIBUTES sa,sa2;
HANDLE hInputRead,hInputWrite;
HANDLE hOutputRead,hOutputWrite;

sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
if (!CreatePipe(&hOutputRead,&hOutputWrite,&sa,0))
{
printf("Error On CreatePipe1");
return;
}

sa2.nLength = sizeof(SECURITY_ATTRIBUTES);
sa2.lpSecurityDescriptor = NULL;
sa2.bInheritHandle = TRUE;
if (!CreatePipe(&hInputRead,&hInputWrite,&sa2,0))
{
printf("Error On CreatePipe2");
return;
}

STARTUPINFO si;
PROCESS_INFORMATION pi;
si.