winapi

Print PDF document with python's win32print module?

I'm trying to print a PDF document with the win32print module. Apparently this module can only accept PCL or raw text. Is that correct? If so, is there a module available to convert a PDF document into PCL? I contemplated using ShellExecute; however, this is not an option since it only allows printing to the default printer. I need to...

SetWindowsHook stops working after some time

I defined a global hook on WM_MOUSE that works perfectly for some time. It post a message to a specific window each time the mouse move. After some random time the hook stop sending messages. If I unregister and register the hook it works again. I suppose some specific thing happening in Windows cause the hook to stop, but I can't find ...

Problem when getting the content of a listbox with python and ctypes on win32

I would like to get the content of a list box thanks to python and ctypes. item_count = ctypes.windll.user32.SendMessageA(hwnd, win32con.LB_GETCOUNT, 0, 0) items = [] for i in xrange(item_count): text_len = ctypes.windll.user32.SendMessageA(hwnd, win32con.LB_GETTEXTLEN, i, 0) buffer = ctypes.create_string_buffer("", text_len+1)...

Help with GCC and ObjectiveC code and Cygwin

Is it possible to build objective c code correctly with GCC under cygwin. I have the following application that should work on a Mac environment, but can't get the most basic stuff to work with gcc. Are there more libraries I need to have. #import "HelloWorldApp.h" int main(int argc, char *argv[]) { return 0; } // End of the //...

can parent window be notified when the hotkey control content changed? (win32)

Hi, I create a window for use setting, it contains a hotkey control and an apply button. In normal way, the button is gray, but I want it be usable when the user set an new hotkey in the hotkey control. I read the relation content in MSDN, but it seems hotkey control doesn't notify its parent window if the hotkey changed. I don't want...

VCL forms application writing to stdout

My company has a large Windows application with a document-object model: open application, open a file, make some changes, save, close. I'm attempting to cut the GUI off of the top and create a console application that accepts some parameters, opens a file, does something useful, saves, closes the file, and terminates. Because there is...

How to send a CBN_SELCHANGE message when using CB_SETCURSEL ?

When using the CB_SETCURSEL message, the CBN_SELCHANGE message is not sent. How to notify a control that the selection was changed ? P.S. I found on the Sexchange site, a very ugly hack : SendMessage( hwnd, 0x014F/*CB_SHOWDROPDOWN*/, 1, 0 ); SendMessage( hwnd, 0x014E/*CB_SETCURSEL*/, ItemIndex, 0 ); SendMessage( hwnd, 0x0201/*WM_LBU...

Recursive directory deletion with WIN32

I've written an application that uses the WIN32 api to create a temporarily directory hierarchy. Now, when wanting to delete the directories when shutting down the application I'm running into some problems. So lets say I have a directory hierarchy: C:\temp\directory\subdirectory\ I'm using this recursive function bool Dir::delete...

Documentation for implementors of COM interfaces

I'm in the process of doing some COM interop from a C# application and I can't seem to find the answer to this. I was wondering where I could find in the Win32 documentation which concreate implementions that exists of a COM interface. For example I know (thanks to goodgle) that IShellLinkW is implemented by a class that's identified by...

FindFileFirst() Invalid handle value for every path

I'm trying to get FindFileFirst() windows API call to work and it's totally failing on every attempt. I've tried ., C:\., .txt, C:\.txt and yet it doesn't even iterate down directory names. Not sure what to try anymore. I'm getting ERROR_FILE_NOT_FOUND 2 (0x2) back when I call GetLastError(). Thanks for any help you can give. HANDLE hFi...

Problem with own Spinlock implementation

I made a very simple spinlock using the Interlocked functions in Windows and tested it on a dual-core CPU (two threads that increment a variable); The program seems to work OK (it gives the same result every time, which is not the case when no synchronization is used), but Intel Parallel Inspector says that there is a race condition at...

Why does WaitForSingleObject(INVALID_HANDLE_VALUE, INFINITE) block?

Why does HANDLE mutexHandle = INVALID_HANDLE_VALUE; WaitForSingleObject(mutexHandle, INFINITE); block? It does not return with an error message. Checking the handle for INVALID_HANDLE would be stupid for a mutex as I would need a mutex for accessing the mutex handle... BTW: It does return with WAIT_FAILED if the handle was closed. ...

Normal looking button with c++ / win32

I'm trying to make a button but it always looks like windows 95 flat button. How do I make it look vista style? hWndEdit = CreateWindowA("button", "Test", WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 100, 20, 140, 20, hWnd, NULL, NULL, NULL); Where ami I going wrong? Thanks ...

How to get Process in windows mobile

Hi, i want to get the running process in .net compact framework windows mobile.. i want to kill the running process.. but i know process.GetProcessesByName() function is present in desktop, but for mobile its not supported i think so.. please let me know how to kill the presently running process in c# windows mobile. Thanks ...

How to ownerdraw the scroll buttons in a scrollable Tmenu (or Tpopupmenu)?

Hi, By setting a MIM_MAXHEIGHT with SetMenuInfo, I can control the max height of a [popup]menu. When the menu appears, if it needs more height than MIM_MAXHEIGHT, it will have 2 scrollbuttons (one at the top, the second at the bottom) I do draw myself the menuitems to theme them with various flavours. But my OnDrawItem or OnMeasureItem...

How to determine the names of all installed keyboard layouts?

To determine the name of the active keyboard layout, one can get its "numeric name" by invoking GetKeyboardLayoutName and then looking it up under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\{0}\Layout Text. However, inexplicably, there appears to be no way to convert the locale identifiers returned by GetKeyboa...

Calling WNetAddConnection2 from PowerShell

I am trying to directly call some Win32 API's from a PowerShell script. I managed to make WNetAddConnection work with the code below: $cp = New-Object Microsoft.CSharp.CSharpCodeProvider $cpar = New-Object System.CodeDom.Compiler.CompilerParameters $Code = @" using System; using System.Runtime.InteropServices; namespace Win32Api { ...

How to detect whether a monitor is widescreen in Windows

I need a way to programatically detect whether the monitor is wide or not, in Windows. GetSystemMetrics returns the size of the desktop, which sort of works, but if an user has a widescreen monitor at, say, 1024x768, I'll incorrectly classify it as non-wide. GetDeviceCaps has similar problems with HORZRES and VERTRES, and even HORZSIZE...

How to recover the INF file from an installed XP printer driver?

I am trying to build a utility to export an installed printer driver from a Windows machine. All is well and good on Vista and higher, because the InfPath entry in the driver's registry key points at the INF file. However, on previous versions of Windows, this doesn't exist. Sometimes I can find the INF file for a printer by scanning C:...

Getting the icon associated with a running application using WinAPI

How can I get the icon of a running application provided I know the Hwnd? ...