winapi

Win32 -- how to manage my mouse hook thread

I have successfully gotten my low-level mouse hook code to work, but there are some behaviors I'm observing that I don't quite understand. Everything works fine if I spawn a thread which installs the mouse hook. When i no longer need it running, I let the thread get destroyed automatically as I exit the program, and I imagine I can easil...

Problem with a custom drawn list view

I created a list view class that uses Custom Draw for its rendering. It all works well except that it doesn't render anything. I subclassed its parent window to catch the NM_CUSTOMDRAW notification as a WM_NOTIFY message. However, it appears that WM_NOTIFY is only triggered a few times during creation of the control and never again after...

WinAPI/GDI: why snapshot of large windows includes taskbar?

Hello people. I am using GDI+ to take window snapshot, the code is: CComBSTR bstrfname (fname); HDC hdc = CreateCompatibleDC (hDC); HBITMAP hbmp = CreateCompatibleBitmap (hDC, CFG_WIDTH, CFG_HEIGHT); HBITMAP hbmp0 = (HBITMAP)SelectObject (hdc, hbmp); BitBlt (hdc, 0, 0, CFG_WIDTH, CFG_HEIGHT, hDC, 0, 0, SRCCOPY); Gdiplus::Bitmap ...

Set focus on console in Windows?

Is it possible to set focus on a console app in Windows? SetFocus looks promising, but it needs an HWND and I don't know if console apps even have one. ...

Automating Windows GUI Testing - FindWindowEx and Control Classes

I've inherited a C# window's application that I'm not real crazy about. I've got a looming deadline and I'm scared to death that some of my changes might be having adverse effects on existing functionality. I've got a hobbyist background to RoR and I'm fairly comfortable with testing in that framework (using both RSpec and Cucumber). ...

Asynchronous I/O with Named Pipes WinAPI

Ok, I have asked a few questions about different facets of trying to accomplish what I want to do. This time I'm having big issues just reading from a named pipe. I think I have harvested enough information to possibly complete the project I am working on if I can set this up properly. I will include all relevant code below, but my missi...

[Named Pipes] Application to Global Hook DLLs

My objective is conceptually simple: I want to set a GetMessage global hook function that utilizes a shared file handle. The problem arises because to my understanding the DLL containing the hook function is loaded multiple times for each process, each with their own "address space". For this reason I'm led to believe I can't simply hand...

trying to extend ruby with win32 programming

I have some C++ Win32 code that I want to call from Ruby. But the code needs to be set up like this int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) otherwise things don't work right when I try creating windows and stuff. I don't know how to do that with a Ruby extension. What can I do? Is the...

WinInet: How to override Internet Explorer's EnableNegotiate setting?

Our application uses WinInet to download data from a web server that supports Windows Authentication (Negotiate). However, when Internet Explorer's Windows Authentication setting is disabled, we only get an HTTP 401 - Unauthorized error. Both .NET's WebClient and the newer WinHTTP don't show this behaviour, but they are not a feasible o...

what is the relationship between c and win32?

why c method using in win32 ...

What are alternatives to the GetShortPathName function?

I'm looking for a function which can return the 'short' (8.3 notation) path for a given 'long' path. However, the GetShortPathName function (which seemed like a perfect fit) doesn't work for me since it requires thata file with the given long path exists already. What other options do I have for computing the 8.3 path for a given long...

Does Win32 support memory-mapped files (CreateFileMapping) on FAT file systems?

I'm concerned about the dangers of using memory-mapped IO, via CreateFileMapping, on FAT filesystems. The specific scenario is users opening documents directly from USB sticks (yeah, you try and ban them doing this!). The MSDN Managing Memory-Mapped Files article doesn't say anything about file system constraints. Update I didn't have...

SetWindowsHookEx with WH_MOUSE_LL slows down the mouse for several seconds.

Hi, I am using the following code to get mouse messages on the current process. using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { return SetWindowsHookEx(WH_MOUSE_LL, proc, GetModuleHandle(curModule.ModuleName), 0); } For some reason when this code runs the mouse g...

windows anti virus process access level... win32 C++

Possible Duplicate: How can I keep Task Manager from killing my program? how to create such a process via win32 C++ ??? does it require some kernel mode? If you try to close the process of a typical anti virus software from task manager or form processxp it fails... I am looking for a way to make such a process that the use...

Read Anonymous Pipes More than Once while Keeping Connection Open (WinAPI)

So I keep bouncing between named and anonymous pipes and here is my issue. I tried named pipes and they just didn't seem to work properly for what I wanted, so I'm back to anonymous pipes. However, the anonymous pipe needs to read input from a pipe (to a program that I did not create) and continuously read it as more information is avail...

Has anyone managed to get Watir using IE on Ruby 1.9.1 working ?

Hi, I'm new to ruby and am having trouble getting a simple watir script to work with IE on ruby v1.9.1. I can get it to work with ruby v1.8.6 Has anyone managed to use watir with Ruby v1.9.1 ? This is the script i'm using require 'watir' browser = Watir::Browser.new browser.goto 'http://www.ruby-lang.org/' Below are details of ...

Drawing with GDI and text with Qt

Hi I have an existing MFC application which draws some shape on screen, Now A Qt plug in is being developed whose one job is to add some text in the MFC drawing. We are using Qt to draw the text in bitmap and then bitblting that on screen so that MFC Cview shows both together. But when we are trying to print(usign Qprinter for text) Text...

WTSOpenServer returns "access denied"

I'm trying to use the Remote Desktop API on a remote machine that I have Administrator rights on, however the WTSOpenServer call always returns error 5 ("Access denied"). I even tried calling WNetAddConnection2 to establish a session, which works fine (I can connect to IPC$ or C$) on the machine). I can also use the Remote Desktop client...

Embedding Third Party Fonts as resource for Win32 Application

Hi, I was wondering how i can embed a third party font into my app( and use it ) so i can distribute my app with the font of my choice for users who do not have the font installed on their systems. Is this possible, or do i have to distribute the font if i want the users to be able to use the font in question. Thanks. ...

Duplicating file handles between processes error

A DLL has the following shared variables (I'm using MinGW): int iCount __attribute__((section(".str"), shared)) = 0; HANDLE hMainFile __attribute__((section(".shr"), shared)) = NULL; HANDLE hProcess __attribute__((section(".shr"), shared)) = NULL; and the global variable: HANDLE hFile = NULL; This is how I'm handling my DLL_PROCESS...