启动一个程序没有控制台窗口(背景) [英] start a program without a console window (in background)

查看:200
本文介绍了启动一个程序没有控制台窗口(背景)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要开始一个简单的程序,当Windows启动,但我不希望显示与该计划相关的控制台输出窗口。只是为了测试,程序可以是简单的:

I want to start a simple program when windows start but I don't want to show the console output window associated with that program. Just to test, the program can be as simple as:

    int main (int argc, char** argv)
    {
        while (1)
        {
             printf ("hello world...\n");
             Sleep (10000);
        }
    return 0;
    }

编译它为: CL foo.c的

我知道如何启动Windows启动时(投入启动文件夹,创建注册表等)的计划,但我不知道如何隐藏程序启动时自带控制台输出窗口。

I know how to start the program when windows is starting (putting in startup folder, creating registry etc), but I don't know how to hide the console output window that comes when the program is started.

在寻找这一点,我发现我可以用启动/ B foo.exe的。是否有这样做的任何其他方法?有些东西像&放大器;我们在Unix上使用

While searching for this, I found that I can use start /B foo.exe. Is there any other method for doing this? some thing like "&" we use on unix.

我的实际的程序是大,是写在 C ,所以我不能用一些其他办法,我发现了 C#(就像WinMain函数)和的Java (如解释<一个href=\"http://stackoverflow.com/questions/6065618/how-start-a-window-with-main-in-console-project\">here).

My actual program is big and is written in C, so I can not use some other alternatives i found for c# (like WinMain) and java (like explained here).

推荐答案

WinMain函数是不是C#的切入点。 C#中使用静态类的方法;它被称为默认主,但是可以被配置为任何静态类方法

WinMain is not a C# entry point. C# uses a method of a static class; it is called Main by default, but can be configured to any static-class method.

在Windows中,非控制台C程序应该定义的WinMain。然后,您可以使用链接程序的 /子系统链接它们:窗户命令行选项,可调用直接或从CL

In Windows, non-console C programs should define a WinMain. You can then link them using the linker's /subsystem:windows command-line option, invokable either directly or from CL.

这篇关于启动一个程序没有控制台窗口(背景)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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