在空调系统隐藏控制台()函数,赢 [英] Hide console in C system() function, Win

查看:139
本文介绍了在空调系统隐藏控制台()函数,赢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编码开发-C ++ C程序,而我需要使用一对夫妇的Windows。这是很容易的,但在执行中的系统()函数的命令时,程序运行在执行控制台

I am coding a C program in Dev-C++, and I need to use a couple of Windows (CMD) commands. It is easy, but when the command in the system() function is executed, the program runs the console in the execution.

一个例子:

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

    int main()
    {
      system("if not exist c:\my_docs\doc.txt (xcopy /Y doc.txt c:\my_docs\)"); // Cmd command
      system("pause");
      return 0;
    }

存在其他的功能,或不显示在控制台的变形

Exists other function, or a modification that do not shows the console?

感谢您!最好的问候。

推荐答案

您可以用CreateProcess的做到这一点。

You can do it with CreateProcess.

STARTUPINFOW si;
PROCESS_INFORMATION pi;

ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));

if (CreateProcessW(command, arg, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
{
    WaitForSingleObject(pi.hProcess, INFINITE);
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
}

这篇关于在空调系统隐藏控制台()函数,赢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆