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
33
votes
7 answers

How to check if a pointer is valid?

I am well aware of the ugliness of this question, I'd still like to know if it's possible: When a program tries to read/write to an invalid pointer (NULL, unallocated block, etc') windows crashes the application with an access violation…
Hammer
33
votes
3 answers

How can I remove titlebar and taskbar icons of Java programs on Windows 7?

I have written a little app that disables the titlebar and taskbar icons of all windows of the Windows OS in C#. Here is the code: using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace IconKiller { class…
33
votes
5 answers

How can I invalidate the file system cache?

I want to measure/optimize the "cold boot" startup performance of an application, and it's difficult to do this without an actual reboot, which is obviously not an ideal solution. Is there a way I could invalidate entire system's file cache, so that…
user541686
  • 205,094
  • 128
  • 528
  • 886
33
votes
7 answers

Bring window to front -> raise(),show(),activateWindow() don’t work

In my Qt-application I open a URL in the default-browser. Afterwards I want to bring the main-window of my application to the front again. I tried all approaches I could find but none worked. All it does is blink in the taskbar (of Window 7) Here’s…
Hedge
  • 16,142
  • 42
  • 141
  • 246
33
votes
2 answers

Win10 dark theme - how to use in WINAPI?

Starting with October 2018 Update (version 1809) Win10 has support for Dark theme in Windows Explorer. It can be configured here: UI: Desktop | Context Menu | Personalize | Colors | Choose your default app mode = Dark Registry :…
Codeguard
  • 7,787
  • 2
  • 38
  • 41
33
votes
3 answers

How to send text to Notepad in C#/Win32?

I'm trying to use SendMessage to Notepad, so that I can insert written text without making Notepad the active window. I have done something like this in the past using SendText, but that required giving Notepad focus. Now, first I'm retrieving the…
lolcat
  • 645
  • 2
  • 7
  • 12
33
votes
15 answers

How relevant is Win32 programming to modern professionals?

As a big fan of Charles Petzold's books Code and The Annotated Turing I came across his book Programming Windows which teaches Win32 programming in C. I am a freshman computer science student who learned C first, but I use C# and .NET for Windows…
JayLeeRan
  • 332
  • 3
  • 9
33
votes
5 answers

How to call an external program with parameters?

I would like to call a windows program within my code with parameters determined within the code itself. I'm not looking to call an outside function or method, but an actual .exe or batch/script file within the WinXP environment. C or C++ would be…
Will
  • 831
  • 1
  • 8
  • 13
33
votes
4 answers

How to programmatically create a shortcut using Win32

I need to programmatically create a shortcut using C++. How can I do this using Win32 SDK? What API function can be used for this purpose?
sergiom
  • 4,791
  • 3
  • 24
  • 32
33
votes
3 answers

How do I retrieve an error string from WSAGetLastError()?

I'm porting some sockets code from Linux to Windows. In Linux, I could use strerror() to convert an errno code into a human-readable string. MSDN documentation shows equivalent strings for each error code returned from WSAGetLastError(), but I don't…
Drew Hall
  • 28,429
  • 12
  • 61
  • 81
33
votes
3 answers

How do you set the glass blend colour on Windows 10?

Using the undocumented SetWindowCompositionAttribute API on Windows 10, it's possible to enable glass for a window. The glass is white or clear, as seen in this screenshot: However, the Windows 10 Start menu and the notification center, which both…
David
  • 13,360
  • 7
  • 66
  • 130
33
votes
8 answers

How do I force windows NOT to redraw anything in my dialog when the user is resizing my dialog?

When the user grabs a corner of a resizable window, and then moves it, windows first moves the contents of the window around, then issues a WM_SIZE to the window being resized. Thus, in a dialog where I want to control the movement of various child…
Mordachai
  • 9,412
  • 6
  • 60
  • 112
33
votes
1 answer

Can a Windows dll retrieve its own filename?

A Windows process created from an exe file has access to the command string which invoked it, including its file's path and filename. eg. C:\MyApp\MyApp.exe --help. But this is not so for a dll invoked via LoadLibrary. Does anyone know of a way for…
Blorgbeard
  • 101,031
  • 48
  • 228
  • 272
33
votes
3 answers

Marshal.AllocHGlobal VS Marshal.AllocCoTaskMem, Marshal.SizeOf VS sizeof()

I have the following struct: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct WAVEHDR { internal IntPtr lpData; // pointer to locked data buffer internal uint dwBufferLength; // length of data buffer internal…
DxCK
  • 4,402
  • 7
  • 50
  • 89
33
votes
3 answers

What is the range of a Windows HANDLE on a 64 bits application?

On WinAPI, the HANDLE type is defined as a void*, thus on a 64 bit application the HANDLE value may range from 0 to 18446744073709551615. But is that true in practice? Does any documentation specify the integral range of such a HANDLE? If for…
Denilson Amorim
  • 9,642
  • 6
  • 27
  • 31