winapi

What the cost of WSAStartup and WSACleanup?

I have a c++ win32 program that uses sockets to download some data from a server. Before using sockets on Windows, WSAStartup must be called. MSDN says: "There must be a call to WSACleanup for each successful call to WSAStartup. Only the final WSACleanup function call performs the actual cleanup." The easiest way for me is to call WSAS...

DirectShow: Graph works in GraphEdit, not in code

I've built the following graph in GraphEdit: Logitech Webcam -> Infinite Tee Pin Filter -> VideoRenderer. This works fine (with GraphEdit automatically inserting a few intermediate filters between the TEe filter and the VideoRenderer filter). I've tried doing the same thing in code, and it fails when trying to connect the Tee filter to ...

How do you retrieve the original location of a mounted path?

In C++, how can I retrieve the location of a mounted drive? for example, if I have mounted drive s: to c:\temp (using subst in the command line) "subst c:\temp s:" how can I get "c:\temp" by passing "s:" I would also like to know how can it be done for a network drive. (if s: is mounted to "\MyComputer\Hello", then I want to retrieve "...

What is the proper way to cast from an 'OLE_HANDLE' to an 'HICON'?

What is the proper way to cast from an 'OLE_HANDLE' to an 'HICON' for an x64 target build? In particular with a normal C-Style cast, I get this warning when compiling with an x64 config: warning C4312: 'type cast' : conversion from 'OLE_HANDLE' to 'HICON' of greater size Here is the offending code: imgList.Add((HICON)ohIcon); The a...

Windows - Power off an usb device in software

I would like to power cycle an usb device through software on windows. I am doing development on a small usb power microcontroller. This chip will revert to native behavior on a power cycle and allow a code download. Since my code will crash the device when things go wrong -- making it ignore all USB commands -- I have to physically ...

Download Web Page

How do i Download Web Page using C (not with libcurl), OS: Win32 Duplicate of Fetch Web Page in C [closed] and How to fetch HTML in C/C++. ...

Modifying Microsoft Outlook contacts from Python

I have written a few Python tools in the past to extract data from my Outlook contacts. Now, I am trying to modify my Outlook Contacts. I am finding that my changes are being noted by Outlook, but they aren't sticking. I seem to be updating some cache, but not the real record. The code is straightforward. import win32com.client import ...

In Windows, how can I enumerate and get text from another window's controls?

More particularly - I have a window handle of another running application. This application contains a TListControl.UnicodeClass control somewhere (I know this from Winspector). How can I, using the Windows API and that window handle, go through all the items in that list control and get the text from all of the items? You can assume th...

How do you retrieve stylus pressure information on windows?

Is anyone aware of a sane way to get tablet/stylus pressure information on Windows? It's possible to distinguish stylus from mouse with ::GetMessageExtraInfo, but you can't get any more information beyond that. I also found the WinTab API in a out of the way corner of the Wacom site, but that's not part of windows as far as i can tell,...

LINQ in win32 DELPHI

Is it possible to use LINQ in win32 DELPHI applications ...

Win32 File Name Comparison

Does anyone know what culture settings Win32 uses when dealing with case-insensitive files names? Is this something that varies based on the user's culture, or are the casing rules that Win32 uses culture invariant? ...

Win32: Graphical debugger that supports symbol server?

i'm trying to debug a program, that i don't have the source code for: explorer.exe It's a native Win32 application from Microsoft, and symbols are avilable. All i need now is a (graphical) debugger that supports symbols. OllyDbg is a graphical debugger, but doesn't support symbols. Delphi is a graphical debugger, but doesn't support ...

On writing win32 api wrapper with C++, how to pass this pointer to static function

I want to convert function object to function. I wrote this code, but it doesn't work. #include <iostream> typedef int (*int_to_int)(int); struct adder { int n_; adder (int n) : n_(n) {} int operator() (int x) { return x + n_; } operator int_to_int () { return this->*&adder::operator(); } }; int main(void...

How can I indent code in the Vim editor on Windows?

Duplicate: How to indent a selection in gvim (win32)? How do I indent multiple lines quickly in vi? Using vim under linux I can indent a block of code using the VISUAL mode and pressing ">". In vim under Windows this does not happen. This is what happens: Press V, the VIM enter in the VISUAL mode Press 'Down', the VIM exit ...

PrintWindow WPF / DirectX

Anyone know of a way to reliably take a snapshot of a WPF window? The PrintWindow api works well for "standard" win32 windows but since WPF uses DirectX, PrintWindow fails to capture an image. I think that one would need to grab the front buffer for the DirectX object associated with the window, but I am not sure how to do that. Thanks!...

How to detect new or modified files

I found there are two ways to approach it, ReadDirectoryChangesW and FindFirstChangeNotification, I want to know what’s difference between them, performance or other??? ...

Unicode characters in window caption

We're having trouble setting window captions using cyrillic or japanese characters. We either see question marks or random garbage, but not the text we want. We've tried using different encodings, SetWindowText(), SetWindowTextW(), SetWindowTextA(), and so on. We can't even get it to work by passing a string literal to SetWindowText(). ...

Is it reasonable to call CloseHandle() on a thread before it terminates?

I'd like to just create a thread, then call CloseHandle immediately and let the thread die on its own so that I don't have to do extra clean-up work in the 'original' thread (not that cleanup is hard in itself, but it means a fair amount of extra book-keeping which I'd like to avoid). MSDN says that calling CloseHandle() on a thread doe...

Modal operation using IMessageFilter and DoEvents

This is a Windows Forms application. I have a function which captures some mouse events modally till a condition is met. For example, I would like to wait for the user to select a point in the window's client area (or optionally cancel the operation using the Escape key) before the function returns. I am using the following structure: A...

How to set the locale for a process launched by CreateProcess()

When launching a process with CreateProcessW(), is it possible to have the process created with a different MBCP locale/codepage then the one that is configured as the system-wide default code page? In the target process, this should have the same effect as calling _setmbcp(). The target process is not a unicode-enabled and uses a plain...