Click here to Skip to main content
15,746,107 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how can I publish a simple hello word application which could run in every windows OS without a need to install .net framework or virtual machines or huge dll files?

obviously, a simple application do not need to huge space in hard disk

which language is appropriate? can I do it with Qt or something else?

Updated 11-Jan-14 1:21am

You might use, for instance, Visual C++, either for creating a console application or a GUI one.
A GUI application written using WINAPI would have a pretty small executable with minimal additional dependecies (see, for instance "Deployment in Visual C++"[^]).
Share this answer
Well, you have to program directly to the operating system's API. This API is system-specific. On windows it is the Windows API. The Windows API is written in pure C.

A "Hello-World" of the Windows API (AKA, Win32 API):
//"Hello-World" application
#include <windows.h>


int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
     static TCHAR szAppName[] = TEXT ("HelloWin") ;
     HWND         hwnd ;
     MSG          msg ;
     WNDCLASS     wndclass ;         = CS_HREDRAW | CS_VREDRAW ;
     wndclass.lpfnWndProc   = WndProc ;
     wndclass.cbClsExtra    = 0 ;
     wndclass.cbWndExtra    = 0 ;
     wndclass.hInstance     = hInstance ;
     wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
     wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
     wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
     wndclass.lpszMenuName  = NULL ;
     wndclass.lpszClassName = szAppName ;

     if (!RegisterClass (&wndclass))
          MessageBox (NULL, TEXT ("This program requires Windows NT!"), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     hwnd = CreateWindow (szAppName,                  // window class name
                          TEXT ("The Hello Program"), // window caption
                          WS_OVERLAPPEDWINDOW,        // window style
                          CW_USEDEFAULT,              // initial x position
                          CW_USEDEFAULT,              // initial y position
                          CW_USEDEFAULT,              // initial x size
                          CW_USEDEFAULT,              // initial y size
                          NULL,                       // parent window handle
                          NULL,                       // window menu handle
                          hInstance,                  // program instance handle
                          NULL) ;                     // creation parameters
     ShowWindow (hwnd, iCmdShow) ;
     UpdateWindow (hwnd) ;
     while (GetMessage (&msg, NULL, 0, 0))
          TranslateMessage (&msg) ;
          DispatchMessage (&msg) ;
     return msg.wParam ;

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
     return DefWindowProc (hwnd, message, wParam, lParam) ;

Simply compile the above piece of code using C or a C++ compiler and you'll get a nice little *.exe of only about 20KB. This "Hello-World" program runs on almost every version of windows and it is guaranteed to run on every version of Windows after Windows 3.0 .

More Information:
1. Graphical user interface using c++[^]

Share this answer
[no name] 12-Jan-14 6:34am    
Does Windows API support events? like button click? like every events which exist in C#
Captain Price 12-Jan-14 15:46pm    
The Windows API has a message-driven architecture. It's quite different to C#'s event-driven mechanism. However both does the same thing.If you want to know more about the Win32 API, you should buy this book and read. It's hard to explain how the Windows API handles events in a single comment. However in the book I've suggested it's explained nicely.
Captain Price 12-Jan-14 15:48pm    
BTW, I'd like to know if you compiled the above demo-app. :)
[no name] 13-Jan-14 2:48am    
yes, i did, but it had compile errors: :(

C:\Users\Mehdi\Documents\New folder (5)\main.o main.cpp:(.text+0x141): undefined reference to `__imp_GetStockObject'1

C:\Users\Mehdi\Documents\New folder (5)\collect2.exe [Error] ld returned 1 exit status

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900