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
55
votes
22 answers

Does it still make sense to learn low level WinAPI programming?

Does it make sense, having all of the C#-managed-bliss, to go back to Petzold's Programming Windows and try to produce code w/ pure WinAPI? What can be learn from it? Isn't it just too outdated to be useful?
Camilo Díaz Repka
  • 4,805
  • 5
  • 43
  • 68
55
votes
4 answers

How do I make a WPF window movable by dragging the extended window frame?

In applications like Windows Explorer and Internet Explorer, one can grab the extended frame areas beneath the title bar and drag windows around. For WinForms applications, forms and controls are as close to native Win32 APIs as they can get; one…
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
55
votes
3 answers

Vista/7: How to get glass color?

How do you use DwmGetColorizationColor? The documentation says it returns two values: a 32-bit 0xAARRGGBB containing the color used for glass composition a boolean parameter that is true "if the color is an opaque blend" (whatever that…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
54
votes
5 answers

Finding undocumented APIs in Windows

I was curious as to how does one go about finding undocumented APIs in Windows. I know the risks involved in using them but this question is focused towards finding them and not whether to use them or not.
Prashast
  • 5,645
  • 3
  • 30
  • 31
54
votes
7 answers

Why does Sleep(500) cost more than 500ms?

I used Sleep(500) in my code and I used getTickCount() to test the timing. I found that it has a cost of about 515ms, more than 500. Does somebody know why that is?
kookoo121
  • 1,116
  • 2
  • 12
  • 21
54
votes
4 answers

Difference between InvalidateRect and RedrawWindow

When I want to redraw a window, is there any preferred function to call between InvalidateRect and RedrawWindow? For instance, are these two calls equal: (win would be a HWND) RedrawWindow(win, NULL, NULL, RDW_INVALIDATE); InvalidateRect(win, NULL,…
default
  • 11,485
  • 9
  • 66
  • 102
54
votes
5 answers

How can I use pywin32 with a virtualenv without having to include the host environment's site-packages folder?

I'm working with PyInstaller under Python 2.6, which is only partially supported due to the mess MS have created with their manifest nonense which now affects Python since it is now MSVC8 compiled. The problem is that the manifest embedding support…
jkp
  • 78,960
  • 28
  • 103
  • 104
54
votes
3 answers

How to execute GetLastError() while debugging in Visual Studio

You're stepping through C/C++ code and have just called a Win32 API that has failed (typically by returning some unhelpful generic error code, like 0). Your code doesn't make a subsequent GetLastError() call whose return value you could inspect for…
Peter Baer
  • 1,232
  • 3
  • 14
  • 19
54
votes
4 answers

Win32 API function to programmatically enable/disable device

I am writing a small C# app to disable a device (my laptop touchpad) whenever another mouse device is detected, and enable the touchpad again if a mouse is not detected. I am not even able to disable the touchpad in device manager (it is running on…
Dale
  • 12,884
  • 8
  • 53
  • 83
53
votes
2 answers

Embed Text File in a Resource in a native Windows Application

I have a C++ Windows program. I have a text file that has some data. Currently, the text file is a separate file, and it is loaded at runtime and parsed. How is it possible to embed this into the binary as a resource?
Oliver Zheng
  • 7,831
  • 8
  • 53
  • 59
53
votes
9 answers

How can a Windows service execute a GUI application?

I have written a Windows service that allows me to remotely run and stop applications. These applications are run using CreateProcess, and this works for me because most of them only perform backend processing. Recently, I need to run applications…
sep
  • 3,409
  • 4
  • 29
  • 32
53
votes
8 answers

How can I tell if a given path is a directory or a file? (C/C++)

I'm using C and sometimes I have to handle paths like C:\Whatever C:\Whatever\ C:\Whatever\Somefile Is there a way to check if a given path is a directory or a given path is a file?
DylanJ
  • 2,373
  • 3
  • 25
  • 24
52
votes
1 answer

Using WinRT from C?

Watching the //BUILD stuff, I saw that WinRT API's can be consumed by C code: I am rather excited about a fresh C API available to Win32 developers. Where can I find information on the C WinRT API? How is it better than the existing Win32 C API?
Andrew
  • 829
  • 1
  • 8
  • 9
52
votes
6 answers

How to get the word under the cursor in Windows?

I want to create a application which gets the word under the cursor (not only for text fields), but I can't find how to do that. Using OCR is pretty hard. The only thing I've seen working is the Deskperience components. They support a 'native' way,…
blez
  • 4,939
  • 5
  • 50
  • 82
51
votes
5 answers

How can I customize the system menu of a Windows Form?

I want to add the age old About menu item to my application. I want to add it to the 'system menu' of the application (the one which pops up when we click the application icon in the top-left corner). So, how can I do it in .NET?
rsjethani
  • 2,179
  • 6
  • 24
  • 30