开发者

What is the difference between a "Win32 Project", "CLR Empty Project", and "Empty Project" templates in Visual Studio?

开发者 https://www.devze.com 2023-01-16 11:09 出处:网络
I\'ve just recently started working with Visual Studio this summer, primarily on CUDA and OpenC开发者_运维百科V related projects.Prior to this, I had been doing my development on Linux for CUDA using

I've just recently started working with Visual Studio this summer, primarily on CUDA and OpenC开发者_运维百科V related projects. Prior to this, I had been doing my development on Linux for CUDA using Makefiles and the common.mk makefile from NVIDIA.

So my question is as follows: I've not been able to figure out for the life of me what the difference between some of the different project templates are. I know that I've had to use "Empty Project" from the general tab of the Visual C++ options, but that's more trial and error, rather than actually knowing what is going on...


A Win32 project is used if you want to end up with a DLL or a Win32 application usually using the bare WinAPI. A common language runtime (CLR) project is used to create C++/CLI project, i.e. to use C++/CLI to target the .NET platform.

The main difference between projects is what Visual Studio comes up with in terms of pre-created files. A windowed Win32 application for example (what you get when you choose Win32 project, but not a DLL) is created with a file for resources (menus, accelerators, icons etc.) and some default code to create and register a window class and to instantiate this window.


When creating a Win32 project, the linker Subsystem is set to Windows. When creating an empty C or C++ project the subsystem is set to console. Likewise the entry point in the settings for Win32 projects expects a WinMain or DllMain while a console expects an int main. A CLR allows you to mix C++ and .NET which is usually discouraged against.

A Windows subsytem can target executables, dlls, libs or driver/native(sys) files. While a console subsystem targets console binary executables. WinMain is typically used when creating an actual Window application using the CreateWindowEx API, establishing message callbacks and inserting a message handler loop.

A console subsustem with int main can also create a Windowed application only you're better off doing it with WinMain.

A Dll empty project sets the subsystem to Windows and setting to the compiled output to (.dll) as well as the entry point to DllMain/APIENTRY and a static lib will do the same as the Dll except it will set the output to (.lib).

Setting the project to Native subsystem will require the Windows Driver Development Kit to compile drivers.

0

精彩评论

暂无评论...
验证码 换一张
取 消