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
112
votes
3 answers

Dynamically load a function from a DLL

I'm having a little look at .dll files, I understand their usage and I'm trying to understand how to use them. I have created a .dll file that contains a function that returns an integer named funci() using this code, I (think) I've imported the…
user969416
110
votes
10 answers

How do I print to the debug output window in a Win32 app?

I've got a win32 project that I've loaded into Visual Studio 2005. I'd like to be able to print things to the Visual Studio output window, but I can't for the life of me work out how. I've tried 'printf' and 'cout <<' but my messages stay stubbornly…
izb
  • 50,101
  • 39
  • 117
  • 168
109
votes
8 answers

How to make an OpenGL rendering context with transparent background?

Rendering contexts usually have a solid color on the background (black or whatever, see the image below): I'm wondering if it's possible to setup a window, with no decorations AND with the transparent background, while allowing me to render OpenGL…
karlphillip
  • 92,053
  • 36
  • 243
  • 426
106
votes
10 answers

Is gettimeofday() guaranteed to be of microsecond resolution?

I am porting a game, that was originally written for the Win32 API, to Linux (well, porting the OS X port of the Win32 port to Linux). I have implemented QueryPerformanceCounter by giving the uSeconds since the process start up: BOOL…
Bernard
  • 45,296
  • 18
  • 54
  • 69
105
votes
10 answers

How to delete a folder that name ended with a dot (".")?

I got some folders created by malware whose name ended with a dot like C:\a.\ or C:\b.\, etc. I found a solution that can remove such folder with command rd /q /s "C:\a.\" but if I call win API RemoveDirectory, it returns ERROR_FILE_NOT_FOUND. And I…
jerry.liu
  • 1,143
  • 3
  • 9
  • 8
104
votes
8 answers

How to read a value from the Windows registry

Given the key for some registry value (e.g. HKEY_LOCAL_MACHINE\blah\blah\blah\foo) how can I: Safely determine that such a key exists. Programmatically (i.e. with code) get its value. I have absolutely no intention of writing anything back to the…
nolandda
  • 2,254
  • 3
  • 17
  • 19
102
votes
3 answers

How can I get the Windows last reboot reason

I'd like to know what is the Windows API function (if any exists) that provides information about the last Windows reboot source. There are three main possible causes: The computer crashed on a blue screen A user or a program shutdown/restarted the…
Frederic
  • 2,034
  • 3
  • 18
  • 22
99
votes
6 answers

What's the differences between VirtualAlloc and HeapAlloc?

There are lots of method to allocate memory in Windows environment, such as VirtualAlloc, HeapAlloc, malloc, new. Thus, what's the difference among them?
user53670
95
votes
4 answers

Manipulate system/visible clipping region in Windows 1809

Apparently, Microsoft has changed the way clipping works with Windows update 1809, released in late 2018. Before that update, GetClipBox() returned the full client rectangle of a window, even when it was (partially) offscreen. After the update, the…
Johannes Stricker
  • 1,701
  • 13
  • 23
95
votes
6 answers

Can multithreading be implemented on a single processor system?

I have always followed the concept that multithreading can only be implemented on multiple processors system where there are more than one processor to be assigned to each thread and each thread can be executed simultaneously. There is no scheduling…
Ayse
  • 2,676
  • 10
  • 36
  • 61
92
votes
13 answers

What is the easiest way to parse an INI File in C++?

I'm trying to parse an INI file using C++. Any tips on what is the best way to achieve this? Should I use the Windows API tools for INI file processing (with which I am totally unfamiliar), an open-source solution or attempt to parse it manually?
conmulligan
  • 7,038
  • 6
  • 33
  • 44
90
votes
15 answers

How to list physical disks?

How to list physical disks in Windows? In order to obtain a list of "\\\\.\PhysicalDrive0" available.
CiNN
  • 9,752
  • 6
  • 44
  • 57
88
votes
8 answers

How do I get rid of Python Tkinter root window?

Do you know a smart way to hide or in any other way get rid of the root window that appears, opened by Tk()? I would like just to use a normal dialog. Should I skip the dialog and put all my components in the root window? Is it possible or…
Jonas Byström
  • 25,316
  • 23
  • 100
  • 147
87
votes
5 answers

Why is the compiler throwing this warning: "missing initializer"? Isn't the structure initialized?

I'm creating some sort of frontend for a program. To launch the program I'm using the call CreateProcess(), which among other things receives a pointer to a STARTUPINFO structure. To initialize the structure I used to do: STARTUPINFO startupInfo =…
Shantia
  • 1,129
  • 2
  • 9
  • 9
87
votes
2 answers

What's "wrong" with C++ wchar_t and wstrings? What are some alternatives to wide characters?

I have seen a lot of people in the C++ community(particularly ##c++ on freenode) resent the use of wstrings and wchar_t, and their use in the windows api. What is exactly "wrong" with wchar_t and wstring, and if I want to support…
Ken Li
  • 2,578
  • 4
  • 25
  • 26