DEV Community

wireless90
wireless90

Posted on • Edited on

5 3

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.

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;
}
Enter fullscreen mode Exit fullscreen mode

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.

Next

Getting a Handle to a Dynamically Linked Library

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay