winapi

Simulating movement of a window and have it react to collisions

I was reading this topic and I decided to give it a shot. To my astonishment it really seemed easier than what I am making it I guess. I have some confusion about the "DesiredPos" variable. Well at least in my implementation. I am trying to move a window around constantly and have it react like a ball when it hits the monitors edges. Lik...

Windows Services query

Using the method described in the MSDN for registering a Windows Service (ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.WIN32COM.v10.en/dllproc/base/createservice.htm) and using similar code to the supplied example: schService = CreateService( schSCManager, // SCManager database TEXT("Sample_Srv"), // name of servi...

IO Other Operations Performance Counter Explanation

I have received perfmon counters from customer site. We noticed unusual values in \COMPUTERNAME\Process(PROCESS_NAME)**IO Other Operations/sec**. The best explanation for the counter I came up with is:- The average rate at which the process is issuing I/O operations that are neither read nor write operations (for example, a co...

[C++] Simulate holding down a key

Im using: keybd_event(0x41, 0, 0, 0); 0x41 is a 'a'. But that just prints one 'a' to the screen. I need it to hold down the key. And when i call keybd_event(0x41, 0, KEYEVENTF_KEYUP, 0); it must release the key. Is that possible? ...

Finding the Recycle Bin on a local NTFS drive

I'm trying to write some simple code that will return the directory for the recycle bin on a local drive. Seems like it would be simple -- should be a thousand answers on Google. Haven't found one yet :( I HAVE found that FAT and NTFS drives have different base names (RECYCLED and RECYCLER). I've found that 'the' recycle bin is a vir...

WinMain command line arguments

The 3rd param to WinMain provides the command line as an unprocessed string. While that may be useful for allowing you to cope with expansion of wildcards and what-not, is there any chance that lurking somewhere in the Win32 API that there's a way to get the usual C argc, argv version of it? ...

How advisable is not having a message loop in WinMain?

This may be the simplest win32 program ever .. #include <windows.h> int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdLine, int show) { MessageBox(0, "Hello world..", "Salutations!", MB_OK); return 0; } .. which makes no calls whatsoever to the usual GetMessage() call. My question is this: if my program doesn't pr...

How to read and write extended windows file attributes with win32

Hi, I would like to embed some meta data in a windows file. I came across the concept of extended file attributes, which I believe are used for this very purpose. For example, camera name in jpgs, episode name in avis. Apart from some very obscure non-documented kernel APIs, I cannot find how to do this in c/c++ using the win32 api. ...

Determining Window Message Queue Depth

We have an application that uses the window message queue to pass data from a socket to consumer HWNDs (at a rate of ~2100Hz). This application has worked for >2 years. Recently our application has started exhibiting problems where WM_TIMER is not being fired/executed by our application. I think this is due to the data being pumped into ...

How to set default font for all the windows in a Win32 Application?

I want all the controls (edit,list control, etc) in my application to be having the same font which is not the system default. How do i do this? Is there any Win32 API that sets the application default font? ...

How do I read a video camera in a win32 C program

I have this garden variety USB video camera, and it came with two mini-apps, one that just lets you see what the camera sees, and one that records to an .avi file. But what's the API if I want to grab images from the camera in my own C program? I am making the assumptions that it's (1) possible and (2) desirable to make some call and ha...

Is there any special setting of proxy server for WinInet API?

I am using the WinInet API to get to internet files using HTTP. Everything works unless the user goes through a proxy server. I'm using InternetOpen with INTERNET_OPEN_TYPE_PRECONFIG which is supposed to get and use the proxy info from the registry (according to the docs). Do I need to use INTERNET_OPEN_TYPE_PRECONFIG and specify the pr...

Changing the process parent of a process to explorer.exe

I'm using CreateProcess to exec Notepad.exe, but the process parent of notepad is my own AP. When I closed my own AP, the process parent of notepad became to explorer. How would I do to put explorer as process parent for this new opened process? ...

SetWindowsHookEx with WH_MOUSE not capturing mouse moves over HTCAPTION area

I try to use SetWindowsHookEx with WH_MOUSE to capture mouse move events. It work everywhere but over HTCAPTION areas (at least in my code sample ). I can't find any reference to this behavior and I tried to windbg into another application that do the same to monitor mouse moves. The method used is WH_MOUSE as well, and the events are ge...

QT and Win32 Console Appications

I have a Win32 console app that is showing this behavior. 1) Using VC 2005 cl to compile and link, the application works fine. What I mean by working fine is that characters above 128 display correctly according to Code Page 437. 2) When I use QT qmake to construct a project (QT += console) and SOURCES = main.c, the build goes fine a...

How do I programatically get the version of a dll or exe?

I need to get the product version and file version for a dll or exe using Win32 native APIs in C or C++. I'm not looking for the Windows version, but the version numbers that you see by right-clicking on a dll, selecting "Properties", then looking at the "Details" tab. This is usually a four-part dotted version number x.x.x.x. ...

Windows API calls from assembly while minimizing program size

I'm trying to write a program in assembly and make the resulting executable as small as possible. Some of what I'm doing requires windows API calls to functions such as WriteProcessMemory. I've had some success with calling these functions, but after compiling and linking, my program comes out in the range of 14-15 KB. (From a source of ...

Controls on main window using Visual C++ designer?

Is is possible to draw controls using Visual C++ designer on the main window, in the same way you can design dialogs? I'd preferably like to be able to design the main window controls this way without using MFC, rather than creating them on WM_CREATE. EDIT: I don't want a dialog-based app, just to be able to design the main window graph...

Weird behavior caused by using .Net ComboBox properties SelectionStart & SelectionLength in "DropDownList" mode

We have a sample application with such handler for a combobox in "DropDownList" mode: private void comboBox1_Leave(object sender, EventArgs e) { comboBox1.SelectionStart = 0; comboBox1.SelectionLength = 0; } the code above behaves differently depending whether the application has CALLWNDPROC hook loaded or not. If application h...

Overlay Window not drawing correctly when hooking

The requirement is to draw my information in side of another application's window. To take care of z order and so forth hooking WH_GETMESSAGE and draw on WM_PAINT seem good. However some WM_PAINT are intended for the window area of my concern, but other WM_PAINT are for something completely different, like a context menu or button. Exa...