Creating a Windows Project in Visual Studio [Windows PE Internals]

Just a very short blog post on how to create a windows api project in visual studio. Would be referencing this for other articles that I post.

Ensure Project template is of type C++, Windows and Console.

For now, just start with an Empty Project.


This content originally appeared on DEV Community and was authored by wireless90

Just a very short blog post on how to create a windows api project in visual studio. Would be referencing this for other articles that I post.

image

Ensure Project template is of type C++, Windows and Console.

For now, just start with an Empty Project.

image

Give it a project name. I called it as WindowsApiProject.

image

Next right click your project, click Properties.

image

Under Configuration Properties->Linker->System, set the subsystem to Windows.

Hit Apply and Ok.

Now right click your Source folder, and create a new .cpp file.

image

Now lets create a main function.

In Windows Api, we create it with WinMain function instead of main.

#include <Windows.h>

int  WinMain(
     HINSTANCE hInstance,
     HINSTANCE hPrevInstance,
     LPSTR     lpCmdLine,
     int       nCmdShow
)
{
    MessageBoxA(0, "Hello World!", "Bye", 0);

    return 0;
}

And we have our hello world message box.

image

I learnt how to create a simple hello world windows project. I realized the main definition was different then the regular c programs, we should use WinMain instead.

I also learnt how to configure Visual Studio to target the Windows subsystem.


This content originally appeared on DEV Community and was authored by wireless90


Print Share Comment Cite Upload Translate Updates
APA

wireless90 | Sciencx (2021-04-18T14:29:59+00:00) Creating a Windows Project in Visual Studio [Windows PE Internals]. Retrieved from https://www.scien.cx/2021/04/18/creating-a-windows-project-in-visual-studio-windows-pe-internals/

MLA
" » Creating a Windows Project in Visual Studio [Windows PE Internals]." wireless90 | Sciencx - Sunday April 18, 2021, https://www.scien.cx/2021/04/18/creating-a-windows-project-in-visual-studio-windows-pe-internals/
HARVARD
wireless90 | Sciencx Sunday April 18, 2021 » Creating a Windows Project in Visual Studio [Windows PE Internals]., viewed ,<https://www.scien.cx/2021/04/18/creating-a-windows-project-in-visual-studio-windows-pe-internals/>
VANCOUVER
wireless90 | Sciencx - » Creating a Windows Project in Visual Studio [Windows PE Internals]. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/04/18/creating-a-windows-project-in-visual-studio-windows-pe-internals/
CHICAGO
" » Creating a Windows Project in Visual Studio [Windows PE Internals]." wireless90 | Sciencx - Accessed . https://www.scien.cx/2021/04/18/creating-a-windows-project-in-visual-studio-windows-pe-internals/
IEEE
" » Creating a Windows Project in Visual Studio [Windows PE Internals]." wireless90 | Sciencx [Online]. Available: https://www.scien.cx/2021/04/18/creating-a-windows-project-in-visual-studio-windows-pe-internals/. [Accessed: ]
rf:citation
» Creating a Windows Project in Visual Studio [Windows PE Internals] | wireless90 | Sciencx | https://www.scien.cx/2021/04/18/creating-a-windows-project-in-visual-studio-windows-pe-internals/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.