You are here:

C++/Api in c++ code


How to use window API in c / C++ code?
Please give me an example of API used in c /c++.

How to debug multithreading program in visual c++?

Umasankar, Thank you for your question.

To use the Windows API (Win32), you must have the Include and library files. You include at least the 'windows.h' file in your program, and link with the appropriate library files that your program uses.

An example of Windows function calls:

HWND   Wnd; // Handle of the new window
// Create an empty window
Wnd = CreateWindow("STATIC", "My Window", WS_OVERLAPPEDWINDOW, 100, 100,
  300, 300, NULL, NULL, NULL, NULL);
// Wait, handling messages, forever
MSG msg;

while( GetMessage( &msg, NULL, 0, 0 ) )
   TranslateMessage( &msg );
   DispatchMessage( &msg );

(This code has not been tested.)

Debugging multithreaded code is difficult. It is sometimes necessary to add code to sample variables to aid in debugging.

There may be information on this topic available on the Web. Try searching the Web.

David Spector


All Answers

Answers by Expert:

Ask Experts


David Spector


Highly knowledgeable in the C++ language, Visual C++ (MSVC), Windows API, documentation and other quality-assurance techniques, and debugging. Knowledgeable in MFC, COM, GUI design, and object-oriented design.


I have been a software engineer since 1965. I have been published. My specializations have been: biomedical programming, compiler implementation, and many kinds of Windows programming. I don't do Databases or other business-oriented stuff.

Windows?/DOS Developer's Journal, ACM SIGPLAN Notices, and Computer Science Press.

ICCP Systems Programming Certification
Master's degree equivalent in Computer Science

©2016 All rights reserved.