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
10
votes
1 answer

How can I get the process name of the current active window in windows with winapi?

I'm trying to get the current window or the active window and the process name of that window, in Windows with winapi. So, I was able to get the active window with GetForegroundWindow() and I'm using OpenProcess() to get the process, the problem…
SujaM
  • 409
  • 6
  • 16
10
votes
1 answer

Difference between taskkill and taskkill /f

On Microsoft Technet I can read that taskkill has a /f parameter to kill a process forcefully. I wonder what this does internally, to understand the impact of such an action. taskkill (without /f) does not simply send a WM_CLOSE message to the…
Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
10
votes
2 answers

Store passwords securely in Windows

Currently, I'm storing my usernames & passwords in a SQL Server CE database. I would like to use some Windows API in order to securely store my user passwords, so that no other application running on the machine could read them. I'm supporting…
Mugen
  • 8,301
  • 10
  • 62
  • 140
10
votes
2 answers

Handle runtime change of DPI (text size) on Windows 10

On Windows 10, the system no longer requires restart (logoff/logon) to change DPI (text size). My application is not ready for such a runtime change. How does system inform an application that the DPI is changing? What message should I handle? I'm…
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
10
votes
3 answers

Reliable way to programmatically get the number of hardware threads on Windows

I'm struggling to find a reliable way to get the number of hardware threads on Windows. I am running a Windows 7 Professional SP1 64-bit on a machine with dual CPU Intel Xeon E5-2699 v3 @ 2.30GHz totalizing 36 cores and 72 threads. I have tried…
ben
  • 101
  • 3
10
votes
1 answer

Running sample Java app for JavaAccessability in C# with 64-bit Java SDK and 64-bit windows

I have a sample Java app that I got when I downloaded javaaccessablity-2.0.2 that makes use of Java Accessibility (via the Java Access Bridge WindowsAccessBridge-32.dll). Although it calls the getAccessibleContextFromHWND successfully it returns…
krrishna
  • 2,050
  • 4
  • 47
  • 101
10
votes
4 answers

Win32: My Application freezes while the user resizes the window

I write a win32 application. I implemented the message loop myself like this: bool programcontinue = true; while(programcontinue) { while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { …
marc40000
  • 3,167
  • 9
  • 41
  • 63
10
votes
1 answer

How to recognize a WOL (Wake On Lan) request while the PC is running

I wonder if its possible to check if a WOL-request has been received during the computer is already turned on. (pInvoke, c#?) If the computer receives a magic paket and boots, Windows writes an corresponding event-log entry to the System-Log. The…
Cadburry
  • 1,844
  • 10
  • 21
10
votes
3 answers

CreateProcess with new console window, but override some std i/o handles

If you use CreateProcess with the flag CREATE_NEW_CONSOLE, the new process has its standard input, output, and error handles directed to the new console window. If you want to override the I/O streams, you can do so by setting the handles in…
Adrian McCarthy
  • 45,555
  • 16
  • 123
  • 175
10
votes
4 answers

In Windows, should I use CreateFile or fopen, portability aside?

What are the differences, and in what cases one or the other would prove superior in some way?
CannibalSmith
  • 4,742
  • 10
  • 44
  • 52
10
votes
1 answer

Can WM_NEXTDLGCTL be used with non-dialog windows?

The documentation for WM_NEXTDLGCTL states, that this message is to be used with dialogs: Sent to a dialog box procedure to set the keyboard focus to a different control in the dialog box. If this message cannot be used with non-dialog control…
IInspectable
  • 46,945
  • 8
  • 85
  • 181
10
votes
1 answer

union object acts like a structure

UPDATE: If you want to see the original manifestation of this problem read the "Original question" section. In a nutshell: I was modifying a field of a C++ union object, but this had no effect on the rest of the fields and it behaved pretty much…
stanm
  • 3,201
  • 1
  • 27
  • 36
10
votes
1 answer

Win32 API C++ Menu bar

I'm trying to learn some basic win32 api. I see to add items to the menu bar tutorials have mentioned to use something like: hMenubar = CreateMenu(); hMenu = CreateMenu(); AppendMenuW(hMenu, MF_STRING, IDM_FILE_NEW, L"&New"); AppendMenuW(hMenu,…
ss7
  • 2,902
  • 7
  • 41
  • 90
10
votes
1 answer

Which are the differences between WinExec and ShellExecute?

I need to execute another application and I'm wondering if there's a reason why I should use WinExec instead of ShellExecute or vice versa. Which are differences between two methods? Is there one that should be preferred?
Hwau
  • 850
  • 3
  • 12
  • 23
10
votes
4 answers

Resolving RVA's for Import and Export tables within a PE file

I am currently writing a PE parser/loader. I have successfully loaded the PE file into memory using standard c file io, retrieved valid DOS and PE headers (the optional header) as well as gaining access to the PE's sections. My next target is to…
jmgunn
  • 101
  • 1
  • 1
  • 3