Jump to content

A simple WINAPI Tutorial


c++

Recommended Posts

First we start with a message box. This is going to be like the gui version of the C++ "Hello World" Program. I highly recommend buying sublime text to use and a mingw compilier.

//api.cpp

#include <Windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,

LPSTR szCmdLine, int iCmdShow)

{

MessageBox(0,"Hello World","Hello World", MB_YESNOCANCEL | MB_ICONINFORMATION);

}

Now we add a reply function (a simple beep)

#include <Windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,

LPSTR szCmdLine, int iCmdShow)

{

int reply = MessageBox(0,"Hello World","Hello World",

MB_YESNOCANCEL | MB_ICONINFORMATION);

if(reply==IDYES){

while(1){

Beep(533,1000);

}

}

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.