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

How can I run a child process that requires elevation and wait?

Win 7/UAC is driving me crazy. From within my C++ application, I need to run an executable that requires elevation on Windows 7. I want to fire this thing off and wait for it to finish before proceeding. What's the easiest way to do this? I…
KenG
  • 353
  • 1
  • 3
  • 4
35
votes
5 answers

What is the equivalent to Posix popen() in the Win32 API?

Is there a rough equivalent to the Linux/Unix stdio.h popen() function in the Win32 API? If so, where can I find it? Edit: I need to know this to patch an omission in the D standard library. Any answer must use only standard Win32 API, no…
dsimcha
  • 67,514
  • 53
  • 213
  • 334
35
votes
8 answers

Why do ZeroMemory, etc. exist when there are memset, etc. already?

Why does ZeroMemory(), and similar calls exist in the Windows API when there are memset and related calls in the C standard library already? Which ones should I call? I can guess the answer is "depends". On what?
CannibalSmith
  • 4,742
  • 10
  • 44
  • 52
35
votes
1 answer

What's a ".dll.a" file?

I'm trying to use a open source library from a Windows application, and the only pre-built version I can find comes as a file called "lib.dll.a" What format is this, and can I convert it to a normal dll file?
Roddy
  • 66,617
  • 42
  • 165
  • 277
35
votes
3 answers

Why does CreateProcess give error 193 (%1 is not a valid Win32 app)

The code below fails to start documents. I get error 193 (%1 is not a valid Win32 app). Starting executables work fine. The files are properly associated, they start the corresponding app when double clicked. I have searched SO and elsewhere for the…
Jan Doggen
  • 8,799
  • 13
  • 70
  • 144
34
votes
6 answers

What are the different calling conventions in C/C++ and what do each mean?

There are different calling conventions available in C/C++: stdcall, extern, pascal, etc. How many such calling conventions are available, and what do each mean? Are there any links that describe these?
Prabhu R
  • 13,836
  • 21
  • 78
  • 112
34
votes
5 answers

Power off an USB device in software on Windows

I would like to power cycle an USB device through software on Windows. I am doing development on a small USB power microcontroller. This chip will revert to native behavior on a power cycle and allow a code download. Since my code will crash the…
Perpetual Student
34
votes
5 answers

Get CPU Temperature

I want to get the CPU temperature. Below is what I've done using C++ and WMI. I'm reading MSAcpi_ThermalZoneTemperature, but it's always the same and it's not the CPU temperature at all. Is there any way to get the real temperature of the CPU…
Johnny Mnemonic
  • 3,822
  • 5
  • 21
  • 33
34
votes
8 answers

How to programmatically move Windows taskbar?

I'd like to know any sort of API or workaround (e.g., script or registry) to move (or resize) Windows taskbar to another position including another monitor (if dual monitors). Definitely, we can move task bar by using mouse, but I want to move it by…
minjang
  • 8,860
  • 9
  • 42
  • 61
34
votes
5 answers

How is it possible to access memory of other processes?

I thought that one process cannot read the memory of other processes. But I'm shocked to see an application named "WinHex" which has "RAM Editor" and it is able to access the entire memory. Of all the processes. How is that possible? And it is even…
Alice
  • 471
  • 1
  • 5
  • 6
34
votes
4 answers

Is it safe to cast SOCKET to int under Win64?

I’m working on a Windows port of a POSIX C++ program. The problem is that standard POSIX functions like accept() or bind() expect an ‘int’ as the first parameter while its WinSock counterparts use ‘SOCKET’. When compiled for 32-bit everything is…
Ryck
  • 638
  • 1
  • 6
  • 8
34
votes
1 answer

What happens internally when a file path exceeds approx. 32767 characters in Windows?

In Windows (assume 2000 onwards), a file path can be at most approximately 32767 characters in length. This limitation exists due to the internal handling with UNICODE_STRING in the native API (also on the kernel side, in drivers etc). So far so…
0xC0000022L
  • 20,597
  • 9
  • 86
  • 152
34
votes
4 answers

Replacing WinMain() with main() function in Win32 programs

I searched a little bit on StackOverflow and Google but couldn't get the idea. I want to start my application with this type of user programming: int main() { Window App("Test", 640, 480); while(App.IsOpen()) { // Do the stuff } } But…
MahanGM
  • 2,352
  • 5
  • 32
  • 45
34
votes
8 answers

CreateProcess doesn't pass command line arguments

Hello I have the following code but it isn't working as expected, can't figure out what the problem is. Basically, I'm executing a process (a .NET process) and passing it command line arguments, it is executed successfully by CreateProcess() but…
akif
  • 12,034
  • 24
  • 73
  • 85
34
votes
5 answers

Adding leading underscores to assembly symbols with GCC on Win32?

I have a piece of C code that calls a function defined in assembly. By way of example, let's say foo.c contains: int bar(int x); /* returns 2x */ int main(int argc, char *argv[]) { return bar(7); } And bar.s contains the implementation of bar() in…
Maks Verver
  • 341
  • 1
  • 3
  • 4