winapi

Should i override operators new/delete in my c++ WIn32 applications

Hi, I know Microsoft themselves used to recommend overriding operator new with calls to HeapCreate() and HeapAlloc(), but that was a while ago. See KB139638 for more details. Would i still benefit from overriding new/delete on Win32? What would be the recommended implementation? TIA. ...

Why does my windows console application leak when idling? (And why does the smoking gun point at kernel32.dll??)

Hello everyone. I have a windows multi-threded console application that appears to be leaking approximately 4kb private memory every minute or so. In an effort to localise the leak, I have gradually suspended each thread in the application until the leak stopped, and to my surprise the culprit seems to be a thread named "Win32Thread". ...

What is RIDI_PREPARSEDDATA in GetRawInputDeviceInfo?

Windows API function GetRawInputDeviceInfo has a parameter uiCommand. One of the options is RIDI_PREPARSEDDATA. It says "pData points to the previously parsed data". I don't get what previously parsed data they are referring to. Is it the data that was last sent with WM_INPUT? Or is it data that was returned by any of the functions? Or ...

Win32API: How to determine if EN_CHANGE was because of user action, not software action?

I find this situation comes up from time to time, and I never seem to have a really robust generic solution to it. I have a control - in this example an EDIT control on a dialog. I want to take certain actions in response to the user - and only the user - modifying the contents of the edit control. The edit control can be set programm...

How to get friendly device name from DEV_BROADCAST_DEVICEINTERFACE and Device Instance ID

I've registered a window with RegisterDeviceNotification and can successfully recieve DEV_BROADCAST_DEVICEINTERFACE messages. However, the dbcc_name field in the returned struct is always empty. The struct I have is defined as such: [StructLayout(LayoutKind.Sequential)] public struct DEV_BROADCAST_DEVICEINTERFACE { public int dbcc_s...

Ensure the Last Character in a RichEdit control is Visible

Text is disappearing from the bottom of a RichEdit control window and I'd like to ensure the bottom character is always visible. Obviously, I could manually scroll to the bottom, but I'd like to do it under software control. ...

Capturing command-line output on win32 that hasn't been flushed yet

(Context: I'm trying to monitor a long-running process from a Perl CGI script. It backs up an MSSQL database and then 7-zips it. So far, the backup part (using WITH STATS=1) outputs to a file, which I can have the browser look at, refreshing every few seconds, and it works.) I'm trying to use 7zip's command-line utility but capture t...

Win32API: How to request embedded windows event notifications out to a parent window

Scenario: I would like a window control which is a sub-window in my dialog (a subwindow of a subwindow) to propagate its notification messages out to the dialog window. e.g. A COMBOBOX contains an EDIT control. I have a circumstance where I would really like to know when the EDIT field gains and loses focus (mainly because the stupid CO...

Manual alternative to message map?

I am trying to create a GUI to display information read from a file. So I will need some number of pushbuttons, text fields, and radio buttons - but I won't know how many I need until run-time. I am using Visual Studio 6.0. My toolset is fairly non-negotiable, so please refrain from suggesting Java, or any C++ toolkit that does not co...

How to Find Out Default File Opener with Java?

I need to find out default file opener for a given file on Windows so that I can customize the command arguments and open the file with the default opener/viewer. My real usage scenario is opening multiple multimedia files with user's default media player so that all the files will be added to user's playlist (For the players that can o...

How to use a RichEdit control like a console with the Win32 API?

I have a RichEdit control in my simple application that I wish to simulate a console-like display with. I want to be able to have a buffer of x number of lines (say, 300) and whenever a line is added, I would like to also remove the oldest (top) line if the new line exceeded the threshold x. I would also like it to automatically scroll...

Capturing the effects of SetConsoleTextAttribute when redirected through a Pipe?

I've redirected stdout of a child process spawned with CreateProcess to a pipe. It works fine except that, as far as I can tell, no information about color changes are coming through. The child process is using SetConsoleTextAttribute to change the text color--is it possible to detect this through the pipe and, if so, how? I'm ultimat...

Why is Sleep(1000) resulting in a deadlock?

I have a basic Win32 console app that makes a call to a named pipe, and then Sleep(1000), inside a while(true) loop. After a hundred iterations, Sleep(1000) will hang. I can see no reason for this. Ok, all I'm doing is taking the code found in this MSDN sample, verbatim and running it as the server: http://msdn.microsoft.com/en-us/libra...

Is this a scaleable named pipe server implementation?

Looking at this example of named pipes using Overlapped I/O from MSDN, I am wondering how scaleable it is? If you spin up a dozen clients and have them hit the server 10x/sec, with each batch of 10 being immediately after the other, before sleeping for a full second, it seems that eventually some of the instances of the client are starve...

LVM_GETITEMCOUNT working intermittently on VISTA

There is SysListView32 control.I am trying to get the no of elements in ListView by using API int iCount = SendMessage(hList,LVM_GETITEMCOUNT,0,0); LVM_GETITEMCOUNT returns the no of items properly on XP. But the same call working intermittently on VISTA. On Vista I am getting iCount =0; GetLastError() on vista returns 0x05.Access de...

ShowHTMLDialog and buttons style

I use the win32 ShowHTMLDialog function to display in my application an HTML popup that contains some standard HTML buttons. But for some reasons, these buttons are not rendered the same way they are in IE: they are not rounded and there is no 3D effect. Is there a way to change this programmatically and get something similar to the IE ...

VB6 Lookup Hostname From IP, Specifying DNS Server

I know how to look up a hostname from an IPv4 in VB using the GetHostByAddr Windows API call (this works great). However, that function does not allow one to specify the DNS server to use. Sometimes the default company DNS servers are fine, but other times I need to specify an external DNS server for lookups, and I don't think doing a sh...

With my global hook installed, how do I know when a window begins to move and when it stops moving?

Is there an easy way to figure this out? I guess I can use WM_MOVE to tell me when it begins by keeping a timer. If the window has not received a WM_MOVE message within the last 2 seconds, then I know that it has just begun to move. Then I set another timer and wait for their not to be a message within a period of time (2 seconds). If no...

Loading managed dll into AppDomain from native c++ code.

Hi, I want to load managed assembly into the AppDomain from native c++ code. If it worth something the native code is a CLR profiler so I get notification each time AppDomain is created. ...

Using AVI Cap API's

Hi I am using API cap API to connect my applicaiton to webcam.... can using grabframe api to capture the frame.. Sample funtion to grap the frame is function body Grab() { capGrabFrame(web_cam); capEditCopy(web_cam); OpenClipboard(); HANDLE hClipBoard = GetClipboardData(CF_DIB); BITMAPINFOHEADER* pBITINFO; pBITINFO...