winapi

Get the process handle of a process by image name

I need the simplest way from C using Win32 to get the process handle of another process by its executable file name. The process I am looking for does not have any registered window classes. I also know that if it is running there will be only one instance of it running. ...

Stream sound to loudspeakers on windows

What do I need to know to stream a sound of a given frequency (that is, generated programatically at runtime, not a file) to the loudspeakers of the system on MS Windows? Please be as specific as you can, I have an idea of winAPI, but I'm more of a linux programmer, so function names are welcome. The answer with the most concrete steps...

Win32 API GroupBox: How to get an offset of text in the header

I have a groupbox (BS_GROUPBOX) like this: http://i50.tinypic.com/34osspd.png (Sorry, new users like me cannot insert images directly) The text of header is sets dynamicaly. I need to determine that current text fit width or not. I use GetTextExtentPoint() to determine string width (textWidth) and, of course, I know a size of control (...

Mouse manipulation inside Virtual PC

Hi. I develop an application, which automates some simple tasks inside Virtual PC. Now I faced with problem: I can't figure out how I can manipulate mouse inside VPC. I do something like this: HWND hDW = (HWND)0x000B03E0; // handle to virtual machine screen int x = 70; int y = 130; SendMessage(hDW, WM_LBUTTONDOWN, MK_LBUTTON, MAKE...

What is the right Windows API call to view and kill a task on a remote computer?

From the command line, I can list tasks on a remote machine like this: c:\>tasklist /s some_machine /u admin_user /p admin_user_password Image Name PID Session Name Session# Mem Usage ========================= ======== ================ =========== ============ System Idle Process 0 ...

WM_MOUSELEAVE not being generated when left mouse button is held

In my Win32 app, I don't get WM_MOUSELEAVE messages when I hold down the left mouse button and quickly move the mouse pointer out of the window. But If I, holding down the left mouse button, start from the inside of the window and move slowly past the window edge, it'll generate a WM_MOUSELEAVE. If I don't hold the left mouse button, I...

How does the COMSPEC environmental variable effect a cgi executable?

It appears that a cgi app (in C, VS C++) does not inherit the COMSPEC environmental variable. When adding the variable to the application: _putenv( "COMSPEC=C:\\WINDOWS\\system32\\cmd.exe" ); // C4996 the cgi application no longer executes from the browser but is interpreted as a file for download. (i.e. - Save this file?) My quest...

Get a list of the available drives and their sizes

I know you can use a combination of GetLogicalDrives() and GetDiskFreeSpaceEx() to get the list of drives and their sizes. I've been using GetDiskFreeSpaceEx() with no problem but when I try to use GetLogicalDrives() I ran into a problem: I don't want to have to check each possible letter to see whether it exists or not before passing it...

What error codes does RegOpenKeyEx return on failure?

The MSDN documentation: http://msdn.microsoft.com/en-us/library/ms724897(VS.85).aspx Is strangely silent on what errors this function might return. I'm particularly interested in what error code is returned if the key doesn't exist, but more comprehensive information would be nice too. ...

Change Win32 Window Style

Is there a win32 function to change the style of a window after it has been created? I would like to change the style flags that are specified in CreateWindowEx. Specifically, I would like to convert a standard window to a window with no border and no resize. ...

How to pass generated image/bitmap/GDI objects to other process?

I have a process A that generates HBITMAP GDI objects to be painted on the screen. I have another process B which wants to display the content of images that process A creates. I plan to do the communications/talking using Point-to-Point message queue or by using other message passing; and use shared memory (along with mutex and or even...

Generic Error in GDI+ when calling Bitmap.getHBitmap()

I'm writing an application which as part of it draws an image on a Logitech G15v2 keyboard's LCD. For the most part the function works fine, but after a while of running, one of the lines throws a "Generic Error in GDI+" The problem, according to a stack trace, is in Bitmap.GetHbitmap(): at System.Drawing.Bitmap.GetHbitmap(Color backg...

EN_PROTECTED - Whether it's received depends which dialog a control is placed in

I have this class CMyRichEditCtrl deriving from CRichEditCtrl. I have the following: void CMyRichEditCtrl::PreSubclassWindow() { CRichEditCtrl::PreSubclassWindow(); SetEventMask(GetEventMask() |ENM_CHANGE | ENM_SELCHANGE | ENM_MOUSEEVENTS | ENM_KEYEVENTS | ENM_PROTECTED); CHARFORMAT format = { sizeof(CHARFORMAT) }; form...

WPF: How can I programatically close a PrintDialog ?

How can I programatically close a WPF PrintDialog ? I tried to call Finalize on it trough reflection, and that does not close it either. Here is what I tried with: using System; using System.Reflection; using System.Threading; using System.Windows; using System.Windows.Controls; namespace WpfApplication15 { partial class Window1 : ...

Replace an existing Winform HWND with another one?

Hi, I'm trying to hijack an existing window and replace it with the contents of a Winforms I own. I figured it would be pretty cool swapping the form's inner handle with the one I want to override, and wondered if anyone ever tried it? Cheers, Florian ...

Detect whether the 3gb Switch is on or off programmatically

I've been trying to determine whether the 3GB switch is on or off on the system my program is running by calling GetSystemInfo() and checking lpMaximumApplicationAddress on the SYSTEM_INFO struct. No luck. I think I am doing something wrong. How do you check whether the 3GB switch is on or not on Windows in C? Code is appreciated. tha...

Embedded resources in Win32 Application

I have embedded an EXE as a resource in my Win32 application. I'm looking to the registry for a certain value. If the value is there and correct, then i copy the embedded EXE to the local file system an execute it from there. I don't want it to be extracted from my EXE. Should i do anything to prevent this, or is it impossible already...

Check if a DLL is present in the system

Hi, quick question. I want to find out if a DLL is present in the system where my application is executing. Is this possible in C#? (in a way that would work on ALL Windows OS?) For DLL i mean a non-.NET classic dll (a Win32 dll) (Basically I want to make a check cause I'm using a DLL that may or may not be present on the user system,...

Securing a Flash EXE

My client has a Flash projector EXE and he wants to set-up an on-line serial number control system so he can sell it on-line. The key problem in this project, as far as i see, that the exe is required to run on only one computer. My current plan is below: Request the serial number from user before the installment and check whether it...

OpenProcess on x64 images from Win32 app

This is weird. Earlier, running Windows 7 x64, I had trouble calling the Win32 OpenProcess against 64-bit processes. Googled around a bit, and came to the sinking conclusion this just wasn't gonna happen. Then a funny thing happened. I tried it against the process ID for explorer.exe, and holy carp, it worked! Started throwing other...