调用DOS实现窗口隐藏并且把DOS控制台下输出信息写入文件中保存 笔记.

win7 64 Dev c++ 

HWND hwnd;

hwnd=FindWindow("ConsoleWindowClass",NULL);

if(hwnd)

{

ShowOwnedPopups(hwnd,SW_HIDE);

ShowWindow(hwnd,SW_HIDE);

}

system(" ping www.baidu.com > 1.txt");

:

WinExec("ping www.baidu.com > result.txt",0);

参数0代表隐藏或者

win 7 64 VS2010 :

ShellExecute (NULL,NULL,_T("cmd.exe"),_T("/C ping www.baidu.com > d:\\12345.txt"),NULL,SW_HIDE);

xp 32 VS2010

ShellExecute (NULL,NULL,_T("cmd.exe"),_T("/C pingwww.baidu.com>d:\\12345.txt"),NULL,SW_HIDE);

 

win 7 64 VC++

HWND hwnd;
hwnd=FindWindow("ConsoleWindowClass",NULL);
ShellExecute (hwnd,NULL,"cmd.exe","/C ping spacer.gifwww.baidu.com > d:\\12345.txt",NULL,SW_HIDE);
if(hwnd)
{
ShowOwnedPopups(hwnd,SW_HIDE);
ShowWindow(hwnd,SW_HIDE);
}

#pragma comment (linker, "/ENTRY:mainCRTStartup")

#pragma comment (linker, "/subsystem:windows")

在某些情况下也能完成隐藏

 

 

你可能感兴趣的:(System,信息)