winapi

How do you programmatically eject an USB mass storage device?

How do you programmatically eject(safely remove) an USB mass storage device in Windows (XP)? ...

When should the Win32 InterlockedExchange function be used?

I came across the function InterlockedExchange and was wondering when I should use this function. In my opinion, setting a 32 Bit value on an x86 processor should always be atomic? In the case where I want to use the function, the new value does not depend on the old value (it is not an increment operation). Could you provide an example...

WaitForObject

can anyone please tell me what is the return value of WaitForObject() function . I do not mean the type of return value (int ) . What does it return if the event is signalled and what does it return if the event is not signalled . Thanks ...

How do I guarantee fast shutdown of my win32 app?

I've got a c++ Win32 app that has a number of threads that might be busy doing IO (HTTP calls, etc) when the user wants to shutdown the app. Currently, I play nicely and wait for all the threads to end before returning from main. Sometimes, this takes longer than I would like and indeed, it seems kind of pointless to make the user wait...

Native Windows Application Development Options

Long winded title, short question: If one wants to develop for Windows but not have to rely on any external dependency (no runtime, thus ruling out .net), what supported, alive and fully functioning* alternatives are there? Visual Basic 6 is dead, Visual C++ is obvious and Delphi seems to be the prime choice for that, but I wonder if t...

Enumerate windows like alt-tab does

I'm creating an alt-tab replacement for Vista but I have some problems listing all active programs. I'm using EnumWindows to get a list of Windows, but this list is huge. It contains about 400 items when I only have 10 windows open. It seems to be a hwnd for every single control and a lot of other stuff. So I have to filter this list s...

Can't detect when Windows Font Size has changed C++ MFC

Hi, I'm trying to determine how I can detect when the user changes the Windows Font Size from Normal to Extra Large Fonts, the font size is selected by executing the following steps on a Windows XP machine: Right-click on the desktop and select Properties. Click on the Appearance Tab. Select the Font Size: Normal/Large Fonts/Extra Larg...

Why would WaitForSingleObject return WAIT_FAILED

MSDN says If the function fails, the return value is WAIT_FAILED. To get extended error information, call GetLastError. The code is: HANDLE m_mutex_handle; /**< m_mutex_handle. The handle to the created mutex. */ m_mutex_handle = ::CreateMutex( 0, false, NULL ); ::WaitForSingleObject( m_mutex_handle, INFINITE ); But what...

Create an icon in memory with win32 in python

What's a good way to generate an icon in-memory in python? Right now I'm forced to use pygame to draw the icon, then I save it to disk as an .ico file, and then I load it from disk as an ICO resource... Something like this: if os.path.isfile(self.icon): icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE ...

How do I capture the audio that is being played?

Does anyone know how to programmatically capture the sound that is being played (that is, everything that is coming from the sound card, not the input devices such as a microphone). ...

Suppressing Popups in Windows

Is there an easy way to tell Windows not to display popups on a headless server machine? Currently occasional application popups are causing my app to freeze because no one is available to press 'Okay' on the console. Just logging to the eventlog would be more than sufficient. ...

Hosted .NET runtime and window focus, problem and inconsistencies

We have a Win32 application that hosts the .NET runtime and opens up .NET managed forms from the Win32 portion of the application. These windows are always opened as modal windows. On some machines, when these windows are closed, the Win32 window that lies behind does not get focus, but gets sent behind Word, Outlook, or whatever else ...

how to get the icon of a java application?

I've got a code that lists the running application on a win32 box, and then displays theirs icons. So far so good, I get the hwnd of the app, then call for GetClassLong(hwnd,GCL_HICONSM), and everything's fine. But the case of a java apps is a pain to deal with, as the process answering to my calls is javaw.exe, and not the shiny-pimp...

C++ win32 GUI programming, the shortest path ?

Do you know of a good means of learning C++ win32 (not .Net/MFC/ATL/Wx/Qt..) GUI programming ? A book, a tutorial, an existing project, preferably a hands-on approach with realistic example.. I'm not a beginner, so I don't mind "advanced" starting points.. With thanks. ...

How does _ftime / Windows internal time work?

Hi guys, I have found an interesting issue in windows which allows me to cause the Windows clock (but not the hardware clocks) to run fast - as much as 8 seconds every minute. I am doing some background research to work out how Windows calculates and updates it's internal time (not how it syncs with an NTP servers). Any information anyon...

Set permissions of a directory to be owned by Everyone with all access

I need to change the permissions of a directory to be owned by the Everyone user with all access rights on this directory. I'm a bit new to the Win32 API, so I'm somewhat lost in the SetSecurity* functions. ...

How to receive timer events in CWinApp with MFC?

In MFC I'm trying to set a null handler timer (ie. no windows). But I'm unable to process the WM_TIMER event in the CWinApp MESSAGE_MAP. Is this possible? If so, how? ...

How to determine whether a Windows application is offscreen?

I am trying to debug a strange issue with users that have LogMeIn installed. After a few days, some of my dialogs that my app opens can end up offscreen. If I could reliable detect that, I could programmatically move the dialogs back where they are visible again. Note: this has to work for multiple monitors and use the win32 API. Howeve...

What is the Win32 API function to use to delete a folder?

What are the Win32 APIs to use to programically delete files and folders? Edit DeleteFile and RemoveDirectory are what I was looking for. However, for this project I ended up using SHFileOperation. I found the sample code at CodeGuru helpful. ...

How to correctly use SetWindowsHookEx & CallNextHookEx

I can correctly setup up a windows hook, but I get confused by the line in MSDN that says "Calling the CallNextHookEx function to chain to the next hook procedure is optional, but it is highly recommended; otherwise, other applications that have installed hooks will not receive hook notifications and may behave incorrectly as a result. Y...