winapi

Capturing key press messages

We're building some software for an in-house Kiosk. The software is a basic .net windows form with an embedded browser. The Kiosk is outfitted with a mat that the user steps on. When the user steps on the mat, it sends a key comination through the keyboard. When the user steps off the mat it sends a different key combination. What we...

How do you place sub controls inside a group box?

When I enable common control visual style support (InitCommonControls()) and I am using any theme other then Windows Classic Theme, buttons inside a group box appear with a black border with square corners. Windows Classic Theme appears normal, as well as when I turn off visual styling. I am using the following code: group_box = Crea...

Changing Win32 menu colors

Is there a way to change the colors used by plain Win32 menus (background, text, and highlight) for a single process, without using SetSysColors? (SetSysColors does a global change, which is bad, and if you crash or forget to set the colors back with SetSysColors again before exiting, they will not be restored until you logout.) ...

Programmatically change screen resolution?

Is there a way to programmatically change the screen resolution or enable/disable multiple monitors in Windows XP? For example to change from 1024x768 with one monitor to 1280x104 on two monitors? I would be most interested in a win32 function to do this but anything that can be tied to a windows shortcut would suffice. ...

Determine windows system wide font

What is the Win32 API call to determine the system-wide font (in particular the color) for say Menus. This would be equivalent to going into Appearance Settings - Advanced - and then choosing Menu as the item to look at. I can use GetSysColor to find the colors of various system-wide window elements, but cannot find the equivalent for ...

How can I determine the display idle time from Python in Windows, Linux, and MacOS?

I would like to know how long it's been since the user last hit a key or moved the mouse - not just in my application, but on the whole "computer" (i.e. display), in order to guess whether they're still at the computer and able to observe notifications that pop up on the screen. I'd like to do this purely from (Py)GTK+, but I am amenabl...

What are the possible classes for the OpenThemedata function?

Hi Everybody, I'm trying to call the OpenThemeData (see msdn OpenThemeData) function but I couldn't determine what are the acceptable Class names to be passed in by the "pszClassList" parameter. HTHEME OpenThemeData( HWND hwnd, LPCWSTR pszClassList ); Could anybody tell me what are the acceptable class names that I can pass in...

Get the current working directory for cmd.exe

How can I retrieve the current working directory of cmd.exe? This seems possible. For example using ProcessExplorer, select CMD.exe, right click, properties, Image tab, "Current Directory" relects the directory set using the CD or CHDIR commands. I've looked at the .NET Process and ProcessStartInfo classes (ProcessStartInfo.WorkingD...

Using AdjustTokenPrivileges securely/robustly?

I'm just writing some code that enables the SeDebug privilege in Windows, using AdjustTokenPrivileges. The token came from OpenProcessToken; OpenThreadToken only returns a token if impersonating. A couple of things occur to me: What's the scope of the token? Is it per-process, or per-thread? If I enable a privilege, is that privilege ...

Check username and password of Windows account

I have an installation package that installs a service process that I create. I'd like to prompt the user for the username/password of the account that the service process should run under. I'd like to verify the the username/password combination are valid before continuing with the installation. I have a C DLL that I am using for spe...

How do I detected whether a hard drive is connected via USB?

I am trying to write a little backup program for friends and family and want it to be as simple to use a possible. I don't want to have to ask the user where to backup their data to, I just want to search for and use the first USB hard drive connected to the computer. Obtaining the unique ID of the hard drive would probably be a good ide...

Passing a string to an already running instance of an application

I have an application that detects if there is another instance of the app running and exits if one is found. This part seems to work reliably. My app takes a command-line argument that I would like to pass to the already running instance. I have the following code so far: Project1.dpr program Project1; uses ... AppInstanceControl...

How can I specify a font for a window created through CreateWindow?

I'm creating window using pure Win32 API (RegisterClass and CreateWindow functions). How can I specify a font for the window instead of system defined one? ...

Passing messages from subclass to original WndProc

I have been reading the MSDN documentation on subclassing and I have been successful in handling events in a subclass My issue is with passing messages back to the original WndProc. As an example, if I have a window, with a sub-classed groupbox control and a button as a child of that groupbox, I want to handle the button event in the ...

Timer in a win32 service

Hello all, Can someone please point me to the easiest way to have a timer in a Win32 service? I suppose I could create a dummy window for this purpose or have a second thread do tick counts, but what's best? Is there a more elegant way? Thanks in advance. ...

Create an Application without a Window

How would you program a C/C++ application that could run without opening a window or console? ...

End win32 process vbscript

Hi there, I've got the following code to end a process, but I still receive an error code 2 (Access Denied). strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'MSSEARCH.exe'") For each objProcess in colProc...

How can I stream video from my application to the web?

I have an application that grabs video from multiple webcams, does some image processing, and displays the result on the screen. I'd like to be able to stream the video output on to the web - preferably to some kind of distribution service rather than connecting to clients directly myself. So my questions are: Do such streaming dist...

How do I get a notification when user creates a mount point?

First off, here are the constraints: Must run on XP Must notify of both drive letter assignments and mounting a volume to a folder Must not 'wake' a drive if it is sleeping. I'd really rather not polling the drive. What I've tried: Google I've looked at WMI and the Win32_LogicalDisk class. I can determine which drives are mounted t...

Checking RAM Bays (Windows API)

I know that it is possible to check how much physical RAM is installed using GetPhysicallyInstalledSystemMemory or how much ram the operating system can see using GlobalMemoryStatusEx. However, I am wondering if there is any way to check how much ram a user has installed by slot. That is, to be able to programmatically tell the differe...