Simple Visual C++ Program

Posted by admin | Posted in Software Programs, Visual Programming | Posted on 28-10-2009

0

#include <windows.h>

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow)
{

MessageBox (NULL, TEXT (“Hello, Windows 98!”), TEXT (“HelloMsg”), 0) ;

return 0 ;
}

Step by Step Procedure :

How to Compile and Build the project in Visual C++
Step 1: Select New from the File menu. In the New dialog box, pick the Projects tab.
Step 2: Select Win32 Application. In the Location field, select a subdirectory. In the Project Name field, type the name of the project, which in this case is HelloMsg .  This will be a subdirectory of the directory indicated in the Location field.
Step 3: Create New Workspace button should be checked. The Platforms section should indicate Win32. Choose OK.

Step 4: A dialog box labeled Win32 Application – Step 1 Of 1 will appear. Indicate that you want to create an Empty Project, and press the Finish button.
Step 5: Select New from the File menu again. In the New dialog box, pick the Files tab. Select C++ Source File. The Add To Project box should be checked, and HelloMsg should be indicated. Type HelloMsg.c in the File Name field. Choose OK.Step 6 : Paste the Program

Step 6 : When you’re ready to compile HELLOMSG, you can select Build Hellomsg.exe from the Build menu, or press F7, or select the Build icon from the Build toolbar. (The appearance of this icon is shown in the Build menu. If the Build toolbar is not currently displayed, you can choose Customize from the Tools menu and select the Toolbars tab. Pick Build or Build MiniBar.)

Step 7: You can select Execute Hellomsg.exe from the Build menu, or press Ctrl+F5, or click the Execute Program icon (which looks like a red exclamation point) from the Build toolbar. You’ll get a message box asking you if you want to build the program.

Sample Output will be displayed.