在 C system() 函数中隐藏控制台,Win [英] Hide console in C system() function, Win

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

问题描述

我正在用 Dev-C++ 编写 C 程序,我需要使用几个 Windows (CMD) 命令.很简单,但是当system()函数中的命令被执行时,程序在执行中运行控制台.

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_docsdoc.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?

谢谢!最好的问候.

推荐答案

您可以使用 WinExec("your cmd command", SW_HIDE); 而不是 system("cmd command").

You can use WinExec("your cmd command", SW_HIDE); instead of system("cmd command").

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

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