winapi

PostMessage with priority?

Is it possible to prioritize a message sent with PostMessage (or any of the other related methods)? IIRC, the WM_PAINT message, for instance, is only processed when there are no other messages in the queue. Is it possible to achieve a similiar behavior with custom messages? If I use WM_PAINT with special parameters in order to deliver ...

Shutdown exception handling for Win32/C++

I have a process that handles exceptions great. It calls: _set_se_translator(exception_trans_func); SetUnhandledExceptionFilter(UnhandledExceptionFilterHandler); _set_purecall_handler(purecallHandler); set_terminate(terminateHandler); set_unexpected(unexpectedHandler); _set_invalid_parameter_handler(InvalidParameterHandler); atexit(ex...

Shouldn't NetUserModalsGet() tell me what domain a machine is part of, and where the PDC is?

This question is third on a series. Thanks to Gonzalo and Mattias S for helping me work out the kinks of calling NetUserModalsGet() from C#. This question, unlike the others, isn't really C# specific -- I think. Here's the working code with which I can call NetUserModalsGet() from C# on a remote machine. It works well, but according to ...

Is there a better way to create this game loop? (C++/Windows)

I'm working on a Windows game, and I have this: bool game_cont; LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_QUIT: case WM_CLOSE: case WM_DESTROY: game_cont = false; break; } return DefWindowProc(hWnd, msg, wParam, lParam); } int WINAPI WinMain(/*lots of paramete...

Сatch the start applications

How to catch the start and completion of applications (processes) in Win. How to measure the time of each application? ...

Are there well-defined size limits in FormatMessage?

I am having a problem when arguments passed to FormatMessage are too long. void testMessage(UINT id, ...) { va_list argList; va_start(argList, id); LPTSTR buff = NULL; const char* str = "The following value is invalid: %1"; DWORD success = FormatMessage(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ALLOCATE_BUFFER, ...

Windows 7 GUI reference

I maintain a large C++ application using Win32 and i want to use some of the new controls introduced in Vista/Windows 7 (New ballon help, command links, status bar notofications. I have downloaded the Windows User Experience Interaction Guidelines, but i dont find a corresponding API Reference. I know that some of these controls will b...

Screenshot of window

I'm trying to take screenshots of all open windows, also the minimized ones. Currently I'm using this code: http://www.developerfusion.com/code/4630/capture-a-screen-shot/ But it doesn't work for minimized windows and the areas where there is a Glass effect since Vista like the explorer title bar are black. Can anyone help me out? My o...

Setting a column style? (Unmanaged c++)

I'm currently able to set a listview style VIA the ListView_SetExtendedListViewStyle method, however this makes all columns have the same style. My goal is to only modify one column (to basically have the LVS_EX_UNDERLINEHOT|LVS_EX_UNDERLINECOLD|LVS_EX_TWOCLICKACTIVATE style). Is there a way to modify the style of only one column and no...

Query wave format for a HWAVEOUT handle

Context: I have a piece of code that knows the value of a waveOut handle (HWAVEOUT). However the code did not create the handle, thus the WAVEFORMATEX that was passed to waveOutOpen when creating the handle is unknown. I want to find out the contents of that WAVEFORMATEX struct that was passed to the waveOutOpen call. Some more details...

Skipping data in winsock?

Is it possible to skip a portion of the incoming data on a TCP stream socket, instead of having to read it into a buffer? Preferably, I'm looking for something that also works asynchronously. ...

Is "const LPVOID" equivalent to "void * const"?

And if so, why some Win32 headers use it? For instance: BOOL APIENTRY VerQueryValueA( const LPVOID pBlock, LPSTR lpSubBlock, LPVOID * lplpBuffer, PUINT puLen ); A bit more elaboration: If the API never uses references (or any other C++-only constructs) but only pointers and values, what is the point of having const L...

tryentercritical section undeclared identifier

I get error TryEnterCriticalSection undeclared identifier during compilation. Visual studio knows about the function but the compiler does not. Other Critical Section functions are defined. I have included #define _WIN32_WINNT 0x0400 in stdafx.h per msdn. Definition in winbase.h is surrounded by #if(_WIN32_WINNT >= 0x0400) #endif /* ...

How to use Windows Security Descriptor to prevent executing other applications?

Hi, In one of my recent questions about using CreateDesktop() API call to create a new desktop and execute my own application inside and prevent other applications to be executed in my Desktop someone pointed me to use security descriptors! Is someone here who could tell me how to do that? Thanks in advance! ...

Bypass keyboard,mouse input and let SendInput pass

I'm making user definable key macros to a program. (Those macros are limited to that program.) I'm using TApplicationEvents to record key messages. And then use SendInput to play them back. But I need to disable mouse and keyboard so it wouldn't interrupt playback. I can't use JournalPlaybackProc and JournalRecordProc because they are ...

On Win32, how to detect whether a Left Shift or Right ALT is pressed using Perl, Python, or Ruby (or C)?

On Win32, I wonder how to detect whether Left Shift or Right ALT is pressed using Perl, Python, or Ruby (or even in C)? Not just for the current window, but the global environment overall. Example: when I am typing a document, I can press Right ALT to start the music player written in Ruby, and then press Right ALT again and it can p...

Why nslookup.exe can resolved with a specified DNS server, but there isn't corresponding API in dnsapi.dll?

nslookup.exe www.google.com 127.0.0.1 This command can resolve using DNS server 127.0.0.1, it's impossible to implement a full stack DNS protocol resolver in a 75.0 KB nslookup.exe, so it must have been using dnsapi.dll. So which dll export C function can provide similar gethostbyname() with a specified DNS server in dnsapi.dll? ...

Help ctypes.windll.dnsapi.DnsQuery_A

Hi, I have trouble with DnsQuery API, the *ppQueryResultsSet parameter troubles me. Can anyone show me an example of how to make correct DLL calls in python? import ctypes from ctypes import wintypes from windns_types import DNS_RECORD, IP4_ARRAY #declared here http://pastebin.com/f39d8b997 def DnsQuery(host, type, server, opt=0): ...

Never ending Win32 Message loop

I have the following code: MSG mssg; // run till completed while (true) { // is there a message to process? while(PeekMessage( &mssg, NULL, 0, 0, PM_REMOVE)) { // dispatch the message TranslateMessage(&mssg); DispatchMessage(&mssg); } if(mssg.message == WM_QUIT){ break; } // our stuff will go here!! Render(); listeners...

Windows 7 and SPI_GETSCREENSAVERSECURE

I'm having a problem with the SystemParametersInfo API in C#. I have no problem getting the screensaver timeout, but when I try to get the state of the "On resume display logon screen" checkbox I always get false. [DllImport("user32.dll", EntryPoint = "SystemParametersInfo")] private static extern bool SystemParametersInfo(uint uiAction...