如何编程两个“int main”在一个单独的exe? [英] How can I program two "int main" in a single exe?

查看:256
本文介绍了如何编程两个“int main”在一个单独的exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我目前正在从事一个个人项目,它应该清除你的USB病毒。它取消隐藏所有内容并删除* .lnk文件,autorun.inf文件以及回收器病毒。但无论如何,重点是我制作了一个控制台程序,它的工作原理是
ok,然后我制作了一个GUI程序(也是用C ++编写的),但它在windows xp上不起作用,我不知道为什么。 (我正在使用Dev-C ++的GUI应用程序的默认生成代码)。所以我做了另一个程序,检测操作系统是XP还是更晚,所以如果
是Xp,它应该运行控制台程序代码,如果它是vista或7或8,那么它运行gui,但是因为它是GUI程序,所以它不使用"int main()",而是使用"int WINAPI WinMain()"。相反,所以我不知道如何在代码中包含它
。 

I'm currently working in a personal project, it's supposed to clean your usb from some viruses. It unhides everything and deletes *.lnk files, autorun.inf file, and also the recycler virus. But what ever, the point is I made a console program, and it works ok, then I made a GUI program (also in C++), but it doesn't work on windows xp, I don't know why. (I'm using the default generated code for GUI applications by Dev-C++). So I made another program that detects if the OS is XP or later, so if it is Xp, it's supposed to run the console program code, and if it's vista or 7 or 8, then it runs the gui, but since it's GUI program, it doesn't use "int main()", but a "int WINAPI WinMain ()" instead, so I don't know how to include it in the code. 

那么有什么想法吗?在此先感谢。

So any ideas? Thanks in advance.

推荐答案

您好Plex,

Hi Plex,

为什么你写一个启动器来检测操作系统并启动正确的exe。例如,Launcher将有一个代码,如

Why you write a launcher whihc detects OS and starts proper exe. For example, Launcher will have a code like

int _tmain(int argc, _TCHAR* argv[])
{
    If (Os is xp)
        //Launch command line and wait for exit
    else
        //Launch gui
  return process return code and wait for exit
}

你可以  CreateProcess API  用于启动exe并等待其退出。退货退出代码

You can CreateProcess API for launching exe and wait for its exit. Return exit code

 问候

VV


这篇关于如何编程两个“int main”在一个单独的exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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