Questions tagged [winapi]

The Windows API (formerly called the Win32 API) is the core set of application programming interfaces available for the Microsoft Windows operating systems. This tag is for questions about developing native Windows applications using the Windows API.

The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. It was formerly called the Win32 API; however, the name Windows API more accurately reflects its roots in 16-bit Windows and its support on 64-bit Windows. Almost all Windows programs interact with the Windows API. You can find more help on the Windows API Documentation.

The Windows API (Win32) is primarily focused on the C programming language in that its exposed functions and data structures are described in that language in recent versions of its documentation. However, the API may be used by any programming language compiler or assembler capable of handling the (well defined) low level data structures along with the prescribed calling conventions for calls and callbacks.

42239 questions
74
votes
1 answer

What is the difference between Send Message and Post Message and how these relate to C# ,WPF and Pure windows programming?

What is the difference between Send Message and Post Message ( in terms of pure windows programming) and how these relate to C# ,WPF and Pure windows programming? I am new to Threading and all related stuff so please excuse me for obvious quesiton…
user407269
  • 763
  • 2
  • 6
  • 8
71
votes
7 answers

How can I get a process handle by its name in C++?

I'm trying to get the process handle of, say example.exe, so I can call TerminateProcess on it. How can I do this? Notice, it doesn't have a window so FindWindow won't work.
Malfist
  • 31,179
  • 61
  • 182
  • 269
70
votes
13 answers

Is there a way to find all the functions exposed by a dll

I've been searching for a way to get all the strings that map to function names in a dll. I mean by this all the strings for which you can call GetProcAddress. If you do a hex dump of a dll the symbols (strings) are there but I figure there must me…
minty
  • 22,235
  • 40
  • 89
  • 106
70
votes
7 answers

How to get main window handle from process id?

How to get main window handle from process id? I want to bring this window to the front. It works well in "Process Explorer".
Alexey Malistov
  • 26,407
  • 13
  • 68
  • 88
69
votes
4 answers

Determine the current HINSTANCE?

The HINSTANCE of a win32 application is passed to WinMain, but is there any other way of determining the current HINSTANCE (in case you couldn't tell, I'm very new to win32 programming!)? I need to create a window inside of a library and (since the…
dicroce
  • 45,396
  • 28
  • 101
  • 140
68
votes
8 answers

malloc() vs. HeapAlloc()

What is the difference between malloc() and HeapAlloc()? As far as I understand malloc allocates memory from the heap, just as HeapAlloc, right? So what is the difference?
TCS
  • 5,790
  • 5
  • 54
  • 86
65
votes
9 answers

How to convert char* to wchar_t*?

I've tried implementing a function like this, but unfortunately it doesn't work: const wchar_t *GetWC(const char *c) { const size_t cSize = strlen(c)+1; wchar_t wc[cSize]; mbstowcs (wc, c, cSize); return wc; } My main goal here is…
AutoBotAM
  • 1,485
  • 3
  • 18
  • 24
65
votes
7 answers

How to get installed Windows SDK version?

How can I determine what version of the Windows SDK is installed on my computer? I'm asking so I can install the latest version if it isn't installed already.
Matt
  • 761
  • 1
  • 5
  • 4
64
votes
18 answers

How to make thread sleep less than a millisecond on Windows

On Windows I have a problem I never encountered on Unix. That is how to get a thread to sleep for less than one millisecond. On Unix you typically have a number of choices (sleep, usleep and nanosleep) to fit your needs. On Windows, however, there…
Jorge Ferreira
  • 96,051
  • 25
  • 122
  • 132
64
votes
4 answers

What does "WINAPI" in main function mean?

Could you please explain to me the WINAPI word in the WinMain() function? In the simplest way.. #include int -->WINAPI<-- WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MessageBox(NULL,…
Pyjong
  • 3,095
  • 4
  • 32
  • 50
64
votes
6 answers

How do I get a list of available serial ports in Win32?

I have some legacy code that provides a list of the available COM ports on the PC by calling the EnumPorts() function and then filtering for the port names that start with "COM". For testing purposes it would be very useful if I could use this code…
GrahamS
  • 9,980
  • 9
  • 49
  • 63
63
votes
2 answers

Get current cursor position

I want to get the current mouse position of the window, and assign it to 2 variables x and y (co-ordinates relative to the window, not to the screen as a whole). I'm using Win32 and C++. And a quick bonus question: how would you go about hiding the…
I Phantasm I
  • 1,651
  • 5
  • 22
  • 28
63
votes
3 answers

How to use Win32 API with Python?

How can I use win32 API in Python? What is the best and easiest way to do it? Can you please provide some examples?
kolistivra
  • 4,229
  • 9
  • 45
  • 58
62
votes
10 answers

How do I call ::CreateProcess in c++ to launch a Windows executable?

Looking for an example that: Launches an EXE Waits for the EXE to finish. Properly closes all the handles when the executable finishes.
jm.
  • 23,422
  • 22
  • 79
  • 93
62
votes
5 answers

How can I take a screenshot in a windows application?

How can I take a screenshot of the current screen using Win32?
user63898
  • 29,839
  • 85
  • 272
  • 514