winapi

Subclass another application's control?

Is it possible to subclass another application's control so that my application could do something before the other application executes it's code and receiving the lParam and wParam? Ex: subclassing notepad's Edit control and when the user types, being able to know what the user typed? would SetWindowSubclass work if I provide the hWnd ...

How do I set a system-wide API hook in Delphi?

Does anyone know about system-wide API hooking with Delphi? I downloaded madCodeHook, but it doesn't have any source, so I don't want use it; I want to program it myself. I found an article on Code Project, but it is in C++. Please help me to write it in Delphi 2010. ...

When are IO completion port packets sent and when not?

I'm currently working on an IPC mechanism based on named pipes using a IO completion port. Unfortunately I have some troubles with the msdn documentation because it's quite unclear to me in which cases calls to ReadFile/WriteFile result in a completion packet. The case when FALSE is returned with ERROR_IO_PENDING is clear, but what abo...

Error DV_E_FORMATETC when asking for CFSTR_PRINTERGROUP - Windows 7

WI have a windows shell extension which adds menu items to the printer menu when the printer is right-clicked. The code works fine in Windows 2000, XP, Vista, but in Windows 7 the call to GetData() fails with DV_E_FORMATETC. I've found various threads regarding this but they all appear to be VB/asp related. The FORMATETC and STGMEDIUM st...

StackWalk64 stops at KiUserDispatchException

Hello. I have a process that crashes, and a dll it loads sets an UnhandledExceptionFilter called win32UnhandledExceptionFilter. Inside my function, I create a new process and call WaitForSingleObject on its handle. In my new process, I get the pid of the old process, attach to it and try capturing a stack trace with StackWalk64: ZeroM...

Is it possible for an application to take ownership of a window from another application?

Basically, I have two applications that run sequentially (second is started by the first, and the first exits immediately after.) I'd like to pass ownership of a window the first application created to the second application. The actual contents of the window don't need to be passed along, it's just being drawn in by DirectX. Alternativ...

Understanding the low-level mouse and keyboard hook (win32)

I'm trying to capture global mouse and keyboard input. LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode >= 0) { if (wParam == WM_RBUTTONDOWN) printf("right mouse down\n"); if (wParam == WM_RBUTTONUP) printf("right mouse up\n"); } return CallNextHookEx(0, nCode, wParam, lParam); } HHOOK ...

Windows.h in C using Turbo-C

Hi, I cannot find windows.h in my include folder of Turbo C and hence cannot work with the Win32 api's Can someone please suggest a workaround? thanks ...

Inter-thread communication (worker threads)

Hi all, I've created two threads A & B using CreateThread windows API. I'm trying to send the data from thread A to B. I know I can use Event object and wait for the Event object in another using "WaitForSingleObject" method. What this event does all is just signal the thread. That's it! But how I can send a data. Also I don't want thr...

How is a pipe reading with a size of 4 bytes into a 4 byte int returning more data?

Reading from a pipe: unsigned int sample_in = 0; //4 bytes - 32bits, right? unsigned int len = sizeof(sample_in); // = 4 in debugger while (len > 0) { if (0 == ReadFile(hRead, &sample_in, sizeof(sample_in), &bytesRead, ...

What is a good format for storing sounds on windows compressed?

Currently we use .wav files for storing our sounds with our product. However, these can get large. I know there are many different sound files out there, however what is the best sound file to use that will: 1) Work on all windows-based systems (XP+) 2) Doesn't add a lot of extra code (ie: including a 3 mb library to play mp3's will o...

Ruby FFI on MinGW

I built a (very simple) library, which I can call just fine from another C++ program. But it won't work when I try to get Ruby FFI to link it. It gives FFI::NotFoundError, says it can't find the function exported in the DLL. Where might things have gone wrong? Do I need special treatment when I compile my DLL using g++? I am just bu...

Message map between non-client and client area for Internet Explorer

I have this message map inside my header file: BEGIN_MSG_MAP(CRebarHandler) MESSAGE_HANDLER(WM_SETREDRAW, onSetRedraw) MESSAGE_HANDLER(WM_MOUSEMOVE, onSetRedraw) END_MSG_MAP() The problem is, my mouse cursor MUST always hover on top of the browser bar in order for the onSetRedraw() function to be called/triggered. How can I make...

Why does my timer stop ticking?

I'm creating a drawing application that renders OpenGL when it gets a WM_SCROLL or WM_MOUSEMOVE. The thing is that there are a lot of mouse moves and I only need it to render a maximum of 60 frames per second. So I created a bool in my engine class called CanRender. so in my render() proc I do: if(!CanRender) { return; } CanRender = fal...

Is this a bug (Windows API)?

I had a question about string normalization and it was already answered, but the problem is, I cannot correctly normalize korean characters that require 3 keystrokes With the input "ㅁㅜㄷ"(from keystrokes "ane"), it comes out "무ㄷ" instead of "묻". With the input "ㅌㅐㅇ"(from keystrokes "xod"), it comes out "태ㅇ" instead of "탱". This is Mr. De...

How to implement Outlook Express alike address field control

Hi All, I was thinking about inserting some object (button, panel or static text) into textctrl, like Outlook Express does this. You can see from a pic "group1" is an object, you can double click on it, when you delete it, it gets deleted the whole text not just a part of it. I made some research and this text field is just a sim...

use win32 API to see whether a Windows XPe system has got USB2 or just 1.1.

Is there a way, just using the win32 API, to find out what version of USB is available? The XPe build is pretty barebones and doesn't doesn't have WMI. I considered the USBview technique: enumerate the USB hubs by opening \.\HCD0 through say \.\HCD9, use DeviceIoControl to get the hub name, and looking for an enhanced host controller. ...

How do I hook another applications events?

I'd like to hook the event that is triggered when an application is trying to notify you of something (when its icon background turns orange and starts flashing) so that I can create my own custom notifications (like getting a text message or email) For example I'd like to have an event triggered when I receive an instant message on my...

How to setup timer resolution to 0.5 ms?

I want to set a machine timer resolution to 0.5ms. Sysinternal utility reports that the min clock resolution is 0.5ms so it can be done. P.S. I know how to set it to 1ms. P.P.S. I changed it from C# to more general question (thanks to Hans) System timer resolution ...

Drawing on 8bpp grayscale bitmap (unmanaged C++)

Hi all, I've been attempting to draw on an 8bpp grayscale bitmap without success. Here are some of my attempts. Maybe someone can point out what I'm doing wrong. =================================================== Attempt 1: Create, select, and draw: In constructor: CBitmap bm; bm.CreateBitmap (200, 200, 1, 8, NULL); In OnDraw: ...