在Visual Studio 2010中将控制台项目转换/移植到无形应用程序
Converting/Porting Console Project to Formless App in Visual Studio 2010
我对 C/C++ 知之甚少,但我想将一个C++控制台项目编译为一个常规的 Windows 应用程序。因此,最后该应用程序根本没有表单,仅执行代码。这是我从ufasoft矿工那里得到的代码:
/*###########################################################################################################################
# Copyright (c) 1997-2012 Ufasoft http://ufasoft.com mailto:support@ufasoft.com #
# #
# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License #
# as published by the Free Software Foundation; either version 3, or (at your option) any later version. # #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied #
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License along with this program; #
# If not, see <http://www.gnu.org/licenses/> #
###########################################################################################################################*/
#include <el/ext.h>
using namespace Ext;
#undef main
#undef wmain
extern "C" int __cdecl _my_wmain(int argc, wchar_t *argv[], wchar_t *envp[]);
extern "C" int __cdecl _my_main(int argc, char *argv[], char *envp[]);
int _cdecl ext_main(int argc, argv_char_t *argv[], argv_char_t *envp[]) {
#if UCFG_WCE
RegistryKey(HKEY_LOCAL_MACHINE, "Drivers\Console").SetValue("OutputTo", 0);
#endif
atexit(MainOnExit);
#if UCFG_ARGV_UNICODE
return _my_wmain(argc, argv, envp);
#else
return _my_main(argc, argv, envp);
#endif
}
#if UCFG_WCE
# if UCFG_ARGV_UNICODE
# pragma comment(linker, "/ENTRY:mainWCRTStartup")
# else
# pragma comment(linker, "/ENTRY:mainACRTStartup")
# endif
#endif
如何将其转换为常规的窗口应用程序?我已经将子系统更改为Windows(/SUBSYSTEM:WINDOWS)。然后,我将项目设置中的入口点更改为ext_main。我还必须确保函数获得CMDCommandLine,因为APP需要读取参数。
谢谢你的帮助。
使用 WinMain
:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
return 0;
}
并将Project Properties -> Linker -> Advanced -> Entry Point
上的入口点设置为 WinMain
.
还有/SUBSYSTEM:WINDOWS
,但你已经这样做了。
相关文章:
- 试图在visual studio上用C++创建一个桌面应用程序
- FFmpeg:制作一个应用程序比直接使用ffmepg更好吗
- 在C应用程序中运行C++(带有STL)函数
- 使用VerQueryValue检索应用程序的文件描述
- Qt C++静态thread_local QNetworkAccessManager是线程应用程序的好选择吗
- 使用调试/崩溃报告将应用程序部署到客户端
- C++控制台应用程序阻止退出
- 码头化的C++应用程序是否向后兼容早期的内核版本
- 将应用程序从32位移植到64位时出现问题
- 如何改变c++应用程序的视觉效果
- WM_CTLCOLORSTATIC从未在WIN32应用程序中触发
- PC中的程序和PHONE中的本机描述应用程序之间的数据连接
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 示例外壳应用程序显示的 V8 "segmentation fault (core dumped)"错误
- phytec phyBOARD iMX-6在从闪存而不是SD卡运行qt5 opengles应用程序时表现不佳(FPS减半
- 为什么导入Mixed native/CLR lib.dll的本机C++应用程序没有在Mixed lib.dll中的外部变
- 如何从Windows应用程序输出到标准?
- C++应用程序 MySQL odbc 数据库连接错误:在引发"otl_tmpl_exception<>"实例后终止调用
- 如何在 64 位 vb.net Windows 应用程序中引用 32 位 dll
- 在Visual Studio 2010中将控制台项目转换/移植到无形应用程序