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
85
votes
8 answers

Is an atomic file rename (with overwrite) possible on Windows?

On POSIX systems rename(2) provides for an atomic rename operation, including overwriting of the destination file if it exists and if permissions allow. Is there any way to get the same semantics on Windows? I know about MoveFileTransacted() on…
teratorn
  • 1,489
  • 1
  • 11
  • 12
84
votes
6 answers

How do I programmatically get the version of a DLL or EXE file?

I need to get the product version and file version for a DLL or EXE file using Win32 native APIs in C or C++. I'm not looking for the Windows version, but the version numbers that you see by right-clicking on a DLL file, selecting "Properties", then…
JSBձոգչ
  • 40,684
  • 18
  • 101
  • 169
84
votes
6 answers

How do I use a third-party DLL file in Visual Studio C++?

I understand that I need to use LoadLibrary(). But what other steps do I need to take in order to use a third-party DLL file? I simply jumped into C++ and this is the only part that I do not get (as a Java programmer). I am just looking into how I…
Zombies
  • 25,039
  • 43
  • 140
  • 225
83
votes
3 answers

How to open Explorer with a specific file selected?

I would like to code a function to which you can pass a file path, for example: C:\FOLDER\SUBFOLDER\FILE.TXT and it would open Windows Explorer with the folder containing the file and then select this file inside the folder. (Similar to the "Show…
Jester
  • 3,069
  • 5
  • 30
  • 44
83
votes
3 answers

C# - Detect time of last user interaction with the OS

I'm writing a small tray application that needs to detect the last time a user interacted with their machine to determine if they're idle. Is there any way to retrieve the time a user last moved their mouse, hit a key or interacted in any way with…
djdd87
  • 67,346
  • 27
  • 156
  • 195
80
votes
9 answers

How can we check if a file Exists or not using Win32 program?

How can we check if a file Exists or not using a Win32 program? I am working for a Windows Mobile App.
RK-
  • 12,099
  • 23
  • 89
  • 155
79
votes
4 answers

Is there a way to get the string representation of HRESULT value using win API?

Is there a function in win API which can be used to extract the string representation of HRESULT value? The problem is that not all return values are documented in MSDN, for example ExecuteInDefaultAppDomain() function is not documented to return…
khkarens
  • 1,305
  • 1
  • 11
  • 16
79
votes
32 answers

How to fix "ImportError: DLL load failed" while importing win32api

I'm setting up an autoclicker in Python 3.8 and I need win32api for GetAsyncKeyState but it always gives me this error: >>> import win32api Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed while…
Glxce
  • 901
  • 1
  • 5
  • 5
77
votes
6 answers

How do I decide whether to use ATL, MFC, Win32 or CLR for a new C++ project?

I'm just starting my first C++ project. I'm using Visual Studio 2008. It's a single-form Windows application that accesses a couple of databases and initiates a WebSphere MQ transaction. I basically understand the differences among ATL, MFC, Win32…
John M Gant
  • 18,970
  • 18
  • 64
  • 82
77
votes
7 answers

How to smooth ugly jitter/flicker/jumping when resizing windows, especially dragging left/top border (Win 7-10; bg, bitblt and DWM)?

THE PROBLEM: When I grab the resize border of my Windows app, especially the top or left borders, and resize the window, the contents of the window do resize "live" as I drag, but they resize in a hideous manner that looks like a blatant bug to even…
Louis Semprini
  • 3,515
  • 2
  • 30
  • 31
76
votes
1 answer

What is the difference between the `A` and `W` functions in the Win32 API?

What is the difference in calling the Win32 API function that have an A character appended to the end as opposed to the W character. I know it means ASCII and WIDE CHARACTER or Unicode, but what is the difference in the output or the input? For…
Questionaire
  • 763
  • 1
  • 5
  • 5
76
votes
5 answers

How do you check if a directory exists on Windows in C?

Question In a Windows C application I want to validate a parameter passed into a function to ensure that the specified path exists.* How do you check if a directory exists on Windows in C? *I understand that you can get into race conditions where…
Zach Burlingame
  • 13,476
  • 14
  • 56
  • 65
76
votes
3 answers

Illegal token on right side of ::

I have the following template declaration: template void IterTable(int& rIdx, std::vector& rVarVector, const std::vector& aTable, const…
Adam Haile
  • 30,705
  • 58
  • 191
  • 286
74
votes
3 answers

What does it mean to set the declaration of a function equal to 0? How can you assign an integer to a function?

I was browsing through the sources of a (prefer not to name) GUI Toolkit which wrapped up the Windows API when I found the following function definition in the window class: virtual LRESULT CALLBACK wndProc (HWND, UINT, WPARAM, LPARAM) = 0; What…
ApprenticeHacker
  • 21,351
  • 27
  • 103
  • 153
74
votes
7 answers

Why do you need to recompile C/C++ for each OS?

This is more of a theoretical question than anything. I'm a Comp sci major with a huge interest in low level programming. I love finding out how things work under the hood. My specialization is compiler design. Anyway, as I'm working on my first…
Nassim Assaf
  • 773
  • 5
  • 5