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

Is there a SetText message for the Win32 ListBox control?

This is easy in .NET (not my question) but I'm trying to figure out if it is possible to simply change the text of a string in a Win32 list box control given an index. There is a GetText function that takes an item index but nothing to change the…
Jared Updike
  • 7,165
  • 8
  • 46
  • 72
10
votes
3 answers

How can I write a screen saver for Windows in C++?

I want to write a screen saver for Windows using the Windows API. How can I start to write it?
kalani
  • 111
  • 1
  • 1
  • 3
10
votes
5 answers

How to determine if the current window is the active window?

How can I tell if my window is the current active window? My current guess is to do GetForegroundWindow and compare the HWND with that of my window. Is there a better method than that? I'm using Win32 API / MFC.
Mark Ingram
  • 71,849
  • 51
  • 176
  • 230
10
votes
1 answer

How to Determine Text Cursor Position in Windows

What is the best way to determine the screen co-ordinates of the currently active text input cursor? I need this for an in-line transliteration program so that I can display some suggestions options to the user as the text is entered.
dparakh
  • 170
  • 1
  • 7
10
votes
3 answers

WinAPI and UTF-8 support

Quick question regarding UTF-8 support and various Win32 API's. In a typical C++ MFC project, is it possible for MessageBox() to display a UTF-8 encoded string? Thanks, Andrew
Andrew
10
votes
1 answer

How to detect if monitor is a projector?

Is there a way to use the Windows APIs to detect if a particular monitor is a projector (beamer) rather than a screen? (I'm writing a projection mapping desktop application, and I'd like it to automatically detect if a projector is attached and…
Adrian McCarthy
  • 45,555
  • 16
  • 123
  • 175
10
votes
3 answers

How do you use SymLoadModuleEx to load a PDB file?

I'm trying to call SymLoadModuleEx to load the symbols from a PDB file and then use SymFromAddr to look up symbols from that PDB. However, I can't figure out what to pass for the parameters BaseOfDll and DllSize -- the documentation explicitly says…
Adam Rosenfield
  • 390,455
  • 97
  • 512
  • 589
10
votes
2 answers

Where is the digital signature stored when code signing a exe file in windows?

As stated in the question title. However, I am using a "trick" where i store extra data after the executable to be used at runtime (see here). Signing my executable appears to break this 'trick' however, so my question is where is the signature…
horseyguy
  • 29,455
  • 20
  • 103
  • 145
10
votes
1 answer

OpenProcessToken failing with Access Denied (5) on Windows XP

My prototype code works fine on every Windows OS I've been able to test on, except Windows XP. When I run this on Windows XP as Administrator, I'm given Access is denied (5) when calling OpenProcessToken. Is there some difference I'm not aware…
wulfgarpro
  • 6,666
  • 12
  • 69
  • 110
10
votes
2 answers

Correct return value of "WindowProc" in a Win32 application

In MSDN's Win32-Api documentation (at http://msdn.microsoft.com/en-us/library/ms633573%28VS.85%29.aspx) on the WindowProc, it states: The return value is the result of the message processing and depends on the message sent. Since I have to implement…
René Nyffenegger
  • 39,402
  • 33
  • 158
  • 293
10
votes
8 answers

A way to ensure that a system tray icon is removed... guaranteed

Is there a way to guarantee that your system tray icon is removed? To add the system tray icon you do: Shell_NotifyIcon(NIM_ADD, &m_tnd); To remove the system tray icon you do: Shell_NotifyIcon(NIM_DELETE, &m_tnd); What I want to know: what if you…
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
10
votes
3 answers

Outputting Hello World in MASM using WIN32 Functions

Contents Intro Code Assembling and Running Miscellaneous Question 1. Intro This isn't a question per se (though there is one at the bottom) but a HelloWorld app for people on StackOverflow to experiment with. When I was first trying programing…
Zimm3r
  • 3,369
  • 5
  • 35
  • 53
10
votes
3 answers

How to enable/disable Windows 10 battery saver in program?

I'm writing a small program to save my laptop's battery, and I can now switch between power schemes using PowerSetActiveScheme. The next step is to control the battery saver in Windows 10. Though I can read the state of it using…
Alan20210202
  • 117
  • 1
  • 3
10
votes
1 answer

Delphi - how to check for any windows user if it is an administrator?

I need to check what kind of accounts are available on a local machine. I already found how I can do this for the current logged user: function IsWindowsAdmin: Boolean; var hAccessToken: THandle; ptgGroups: PTokenGroups; dwInfoBufferSize:…
Georgi Bonchev
  • 269
  • 4
  • 12
10
votes
4 answers

Win32 API for rename a file in C

If the source directory and the target directory, MoveFile would actually make a copy of the source file into the target file, which means that I will end up seeing two files. Is that the best way that rename can be achieved?
tom
  • 14,273
  • 19
  • 65
  • 124