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

How do I send key strokes to a window without having to activate it using Windows API?

    I have made an application already that sends commands to an activated window. I want to be able to use the computer while my process is running because as soon as I switch focus to another window the key strokes being sent via send keys will go…
SlipToFall
  • 415
  • 1
  • 4
  • 8
38
votes
19 answers

Is Learning the win32 API Worthwhile?

I was certain that somebody would have specifically asked this question, but from what I can see no-one has (there's been a question about learning win32 but that doesn't cover whether it's worthwhile doing so). I am very interested in gaining a…
ljs
  • 37,275
  • 36
  • 106
  • 124
38
votes
5 answers

How do I get the HMODULE for the currently executing code?

I have a static library that may get linked into either a .exe or a .dll. At runtime I want one of my library functions to get the HMODULE for whatever thing the static library code has been linked into. I currently use the following trick…
pauldoo
  • 18,087
  • 20
  • 94
  • 116
38
votes
3 answers

What exactly is the scope of Access Violation '0xc0000005'?

I was wondering about exception 0xc0000005 and what it acctually encompasses. I.e. I take it this occurs if an application tries to access freed memory/memory belonging to another process. But what about, for example, an address mapped for hardware?…
sebf
  • 2,831
  • 5
  • 32
  • 50
38
votes
3 answers

Detect active window changed using C# without polling

How might one invoke a callback whenever the current active window changes. I've seen how it might be done using CBTProc. However, global events aren't easy to hook into with managed code. I'm interested in finding a way that doesn't require…
Joe
  • 1,043
  • 2
  • 12
  • 21
38
votes
3 answers

How do I get the file HANDLE from the fopen FILE structure?

The fopen function returns a pointer to a FILE structure, which should be considered an opaque value, without dealing with its content or meaning. On Windows, the C runtime is a wrapper of the Windows API, and the fopen function relies on the…
lornova
  • 6,667
  • 9
  • 47
  • 74
38
votes
13 answers

C++/Win32: How to wait for a pending delete to complete

Solved: Workable solution: sbi's answer Explanation for what really happens: Hans's answer Explanation for why OpenFile doesn't pass through "DELETE PENDING": Benjamin's answer The Problem: Our software is in large part an interpreter engine for a…
Mordachai
  • 9,412
  • 6
  • 60
  • 112
38
votes
3 answers

How to embed WebKit into my C/C++/Win32 application?

The solutions I have found are irrelevant: someone used WebKit in a Delphi project someone used it with Java there is QtWebKit (about:blank demo app takes 44 megs) .Net port of it GTK+ port I need a guide how to embed WebKit instance into a pure…
Pavel Vlasov
  • 4,206
  • 6
  • 41
  • 54
38
votes
4 answers

Alignment requirements for atomic x86 instructions vs. MS's InterlockedCompareExchange documentation?

Microsoft offers the InterlockedCompareExchange function for performing atomic compare-and-swap operations. There is also an _InterlockedCompareExchange intrinsic. On x86 these are implemented using the lock cmpxchg instruction. However, reading…
jalf
  • 243,077
  • 51
  • 345
  • 550
38
votes
14 answers

How to programmatically unplug & replug an arbitrary USB device?

I'm trying to fix a non-responsive USB device that's masquerading as a virtual COM port. Manual replugging works, but there may be up to 12 of these units. Is there an API command to do the programmatic equivalent of the unplug/replug cycle?
Dean
38
votes
11 answers

Best method for storing this pointer for use in WndProc

I'm interested to know the best / common way of storing a this pointer for use in the WndProc. I know of several approaches, but each as I understand it have their own drawbacks. My questions are: What different ways are there of producing this kind…
Mark Ingram
  • 71,849
  • 51
  • 176
  • 230
37
votes
2 answers

How to get screen resolution in C++?

Possible Duplicate: How to get the Monitor Screen Resolution from an hWnd? Is there a way to get the screen resolution in C++? I have searched MSDN but with no luck. The closest thing I found was ChangeDisplaySettingsEx() but that doesn't seem to…
Nate Koppenhaver
  • 1,676
  • 3
  • 21
  • 31
37
votes
4 answers

What is the difference between GetClientRect and GetWindowRect in WinApi?

What of these should I use in InvalidateRect to refresh my window? And why?
Abzac
  • 2,631
  • 5
  • 21
  • 24
37
votes
5 answers

How do I compute the non-client window size in WPF?

WPF has the SystemParameters class that exposes a great number of system metrics. On my computer I have noticed that a normal window has a title that is 30 pixels high and a border that is 8 pixels wide. This is on Windows 7 with the Aero theme…
Martin Liversage
  • 104,481
  • 22
  • 209
  • 256
37
votes
7 answers

How can I open a local HTML file in Microsoft Edge browser?

Since time immemorial, most web browsers have been able to open a local file if you ran the web-browser executable, for example just execute iexplore.exe file:/c:/temp/file or via the IShellDocView interfaces. I am trying to do this from within my…
Warren P
  • 65,725
  • 40
  • 181
  • 316