winapi

In what thread does a low-level mouse and keyboard hook callback run?

I'm setting a low-level mouse hook with SetWindowsHookEx: HANDLE handle = SetWindowsHookEx(WH_MOUSE_LL, &callback, GetModuleHandle(NULL), NULL); Because this is a low-level callback, it will be executed inside my own process; no DLL injection is performed. Now, I've noticed that the callback sometimes (indirectly) gets invoked from s...

Getting security information for remote registry keys?

According to the documentation for API function GetNamedSecurityInfo, it can get information from the following objects: Local or remote files or directories on an NTFS file system Local or remote printers Local or remote Windows services Network shares Registry keys Semaphores, events, mutexes, and waitable timers File-mapping objects...

Getting BIOS serial number

How do I get the BIOS serial number without using WMI API under Win32? I need a non WMI way cause WMI calls under Windows Guest account return as access denied. ...

IcmpSendEcho and setting MTU size ?

Does anyone know if its possible to adjust the MTU while sending an ICMP echo packet (with IcmpSendEcho)? I'm trying to do this under Windows using the IcmpSendEcho() function. ...

ComboBoxEx32 (CComboBoxEx) keyboard behaviour

I have a WTL application that uses an extended combobox control (the Win32 class ComboBoxEx32) with the CBS_DROPDOWNLIST style. It works well (I can have images against each item in the box) but the keyboard behaviour is different to a normal combobox - pressing a key will not jump to the first item in the combo that starts with that le...

Find window with variable caption

I'm using WinApi and C#. I need to find window with variable caption. Caption contains constant part. I think that I need to enumerate all windows. How I can do this? ...

Listview controls don't appear in dialog

C++ win32 application (not MFC), whose GUI comprises just one dialog box from the resource file [WinMain() calls DialogBox()]. This works fine. However, adding any "common controls" (listview, tab control, etc) to the dialog and they don't appear when the program is run. Normal controls (textbox, button, radiobox etc) are displayed, j...

is there a better way to select correct method overload?

Is this really the only way to get the correct address for an instance function: typedef CBitmap * (CDC::* SelectObjectBitmap)(CBitmap*); SelectObjectBitmap pmf = (SelectObjectBitmap)&CDC::SelectObject; First, one has to create a typedef, and then one has to use that to force the compiler to select the correct overloaded method when t...

Programatically enable / disable multitouch finger input?

I have a multitoch-enabled tablet PC running Windows 7. However, when using the stylus pen and getting too far away from the display, I often accidently hit it with my fingers which causes unwanted mouse-clicks. The solution is navigating to "Control Panel - Pen- and Finger Input - Finger Input" and deactivate the checkbox "Use the fin...

CComModule UnregisterServer error?

I have a CComModule that is calling RegisterServer (TRUE) on DllRegisterServer and UnregisterServer (TRUE) on DllUnregisterServer. The UnregisterServer is getting a 0x8002801C (Error accessing the OLE registry.) error and leaving around registery keys. I am using a Windows Server 2k8 R2 machine with UAC enabled. The components are x86 an...

How to programmatically move Windows taskbar?

I'd like to know any sort of API or workaround (e.g., script or registry) to move (or resize) Windows taskbar to another position including another monitor (if dual monitors). Definitely, we can move task bar by using mouse, but I want to move it by a program, or a sort of automated way. I tried to find Win32 API, but it seems no one do...

Windows Library - Playing Musical Notes

Is there an up-to-date Windows Library which allows the playing of individual musical notes? Even just a wrapper on top of Beep, would suffice, though I don't know if that would be supported on all version of Windows. ...

communication between apps via win messages

hi, i'm trying to let 2 application communicate with each other using windows message. however, i've been getting AccessViolationException (attempted to read or write protected memory) during allocating memory and marshaling of data. Can someone explain to me what's wrong or suggest a better way? Thanks. EDIT: using WM_COPYDATA as su...

Drag Drop using SendMessage

hi guys, This sounds funny..just a little experiment. i wanted to simulate a drag drop of a file on a Application/Window using Send Message. Is it possible? I dont have code for the application but on the executable. The application is IP Messenger. What i wanted to do is use "Send To" functionality to send the file to an .exe ,which ...

The OS doesn't shutdown, but my application does

Hi, I have an application which when I close the Windows, it exits gracefully and quickly (checked also in Task Manager and Process Explorer - the process isn't there anymore) but the OS doesn't. It seems that OS just ignores the Shutdown. But if I try to close once more the Windows, now everything is ok. The system shuts down in a ve...

How can you draw 32bppargb images with the Win32 AlphaBlend function?

I've been fussing with this for the better part of the night, so maybe one of you can give me a hand. I have found GDI+ DrawImage in C# to be far too slow for what I'm trying to render, and from the looks of forums, it's the same for other people as well. I decided I would try using AlphaBlend or BitBlt from the Win32 API to get better...

WinInet and SOAP

Hi, Currently I use the CURL open transport library to genereate http requests with a soap header. This all is implemented in C/C++. I was able to port this to Windows mobile howver I wonder whether I can use WinInet to do the SOAP request? Just to use less memory on the mobile device. Are there samples on how to do this? Thanks in ad...

Why does OpenProcessToken fail with ERROR_ACCESS_DENIED

I'm running a process as a user in the Administrators group, trying to get a process token for another process. The other process is run by a user not in the Administrators group. Here's the gist of the code I'm using. pid in this code represents the process id of the non-admin process. All of this is on Windows XP SP 2 and all on th...

How do you create Windows security descriptors in managed code??

I have a named pipe that's created in a managed process. I have a 2nd process that tries to open a file handle to the named pipe, however the 2nd process is running under an lower privilege than the process that created the named pipe. My understanding is that I need to create the named pipe in the first process with a security descripto...

Should I use _T or _TEXT on C++ string literals?

For example: // This will become either SomeMethodA or SomeMethodW, // depending on whether _UNICODE is defined. SomeMethod( _T( "My String Literal" ) ); // Becomes either AnotherMethodA or AnotherMethodW. AnotherMethod( _TEXT( "My Text" ) ); I've seen both. _T seems to be for brevity and _TEXT for clarity. Is this merely a subjectiv...