winapi

Why would the Win32 OleGetClipboard() function return CLIPBRD_E_CANT_OPEN?

Under what circumstances will the Win32 API function OleGetClipboard() fail and return CLIPBRD_E_CANT_OPEN? More background: I am assisting with a Firefox bug fix. Details here: bug 444800 - cannot retrieve image data from clipboard in lossless format In the automated test that I helped write, we see that OleGetClipboard() sometimes...

How can I open a window's system menu by code?

I have a C# WinForms borderless window, for which I override WndProc and handle the WM_NCHITTEST message. For an area of that form, my hit test function returns HTSYSMENU. Double-clicking that area successfully closes the form, but right-clicking it does not show the window's system menu, nor does it show up when right-clicking the windo...

Is there a buffered version of CComBSTR that makes string concatenation more efficient?

I have several projects where I need to append strings to a BSTR/CComBSTR/_bstr_t object (e.g. building a dynamic SQL statement). Is there an out-of-the-box type in the WinAPI to buffer the concatenation (like StringBuilder in .NET), or do I have to write my own? From what I know about the append methods, they perform re-allocation. ...

Available space left on drive - WinAPI - Windows CE

Hi, I've forgotten the WinAPI call to find out how much space is remaining on a particular drive and pinvoke.net isn't giving me any love. It's compact framework by the way, so I figure coredll.dll. Can anyone with a better memory jog mine? ...

Win32/MFC Get window rect from client rect

I know there is a function somewhere that will accept a client rect and it will convert it into a window rect for you. I just can't find / remember it! Does anyone know what it is? It will do something similar to: const CRect client(0, 0, 200, 200); const CRect window = ClientRectToWindowRect(client); SetWindowPos(...) ...

How do you manipulate GUID's when doing Windows programming in C or C++?

How do you manipulate GUID's when doing Windows programming in C or C++? Thanks to Rich B for fixing my "faux pas" and moving my reply to my own question out of the question itself and into a standalone answer. ...

Perl - Win32 - How to do a non-blocking read of a filehandle from another process?

I'm writing some server code that talks to a client process via STDIN. I'm trying to write a snippet of perl code that asynchronously receives responses from the client's STDOUT. The blocking version of the code might look like this: sub _read_from_client { my ($file_handle) = @_; while (my $line = <$file_handle>) { print ST...

How do I call a Win32 Function in PowerShell 1.0 using P/Invoke?

There are many scenarios where it would be useful to call a Win32 function or some other DLL from a PowerShell script. to Given the following function signature: bool MyFunction( char* buffer, int* bufferSize ) I hear there is something that makes this easier in PowerShell CTP 2, but I'm curious how this is best done in PowerShell 1.0...

WM_GETMINMAXINFO, the ptMaxSize not having any effect

In handling a WM_GETMINMAXINFO message, I attempt to alter the parameter MINMAXINFO structure by changing the ptMaxSize. It doesn't seem to have any effect. When I receive the WM_SIZE message, I always get the same value, no matter whether I increase or decrease the ptMaxSize in the WM_GETMINMAXINFO. ...

High-level languages for out-of-the-box GUI desktop application programming

After I discontinued programming in C++ while entering into web authoring I was spoilt by PHP's high level constructs like hash tables or its dynamic, weak typing. I remembered the angst of C/C++ pointers and the maze of low-level Win32 API handles and message loops and that prevented me from utilizing environments like Code::Blocks for ...

How to get CreateProcess/CreateProcessW to execute a process in a path > MAX_PATH characters

I'm trying to get either CreateProcess or CreateProcessW to execute a process with a name < MAX_PATH characters but in a path that's greater than MAX_PATH characters. According to the docs at: http://msdn.microsoft.com/en-us/library/ms682425.aspx, I need to make sure lpApplicationName isn't NULL and then lpCommandLine can be up to 32,76...

Window styles / Minimal titlebar/borders

I'm looking for some kind of a resource (website) that would list all possible window/dialog frame styles and their respective combinations with images. I'm only really interested in Vista, as my software won't support older platforms anyway. I have a more specific case here too: I'm wondering if there are other ways to achieve a smalle...

Why does GetWindowRgn fail on Vista?

I'm writing a program that uses SetWindowRgn to make transparent holes in a window that belongs to another process. (This is done only when the user explicitly requests it.) The program has to assume that the target window may already have holes which need to be preserved, so before it calls SetWindowRgn, it calls GetWindowRgn to get th...

Any experience with compiling VBScript?

I have a home-spun 2000 lines VBScript script, that has become progressively slow with each additional code I add. It was created as a private debugging aid and now that it has become really useful. I want to polish it and ship it along with our product. I thought I could speed it up by compiling it and making it an EXE. Furthermore I w...

What is the windows API to change Screen refresh rate?

Can some one specify the windows API, one need to use in order to be able to change programmatically the screen refresh rate? ...

How can i tell if a given path is a directory or a file? (C/C++)

I'm using C and sometimes i have to handle paths like C:\Whatever, C:\Whatever\ or C:\Whatever\Somefile Is there a way to check if a given path is a directory or a given path is a file? :O ...

CScrollView and window size

(MFC Question) What's the best way to determine the current displayed client area in a CScrollView? I only need the size of the visible portion, so GetClientRect() won't work here. ...

Converting Win16 C code to Win32

In general, what needs to be done to convert a 16 bit Windows program to Win32? I'm sure I'm not the only person to inherit a codebase and be stunned to find 16-bit code lurking in the corners. The code in question is C. ...

How do you write the end of a file opened with FILE_FLAG_NO_BUFFERING?

I am using VB6 and the Win32 API to write data to a file, this functionality is for the export of data, therefore write performance to the disk is the key factor in my considerations. As such I am using the FILE_FLAG_NO_BUFFERING and FILE_FLAG_WRITE_THROUGH options when opening the file with a call to CreateFile. FILE_FLAG_NO_BUFFERING ...

What is a good MFC starting book?

Hey all. Any one have any recommendations for a great MFC book that I can learn? I have background in .NET and C++. Thanks! ...