winapi

Can abusing RegisterWindowMessage lead to resource exhaustion?

MSDN advises that RegisterWindowMessage() function is only used for registering messages to be sent between the processes. If a message is needed for sending within one process it can be safely selected from the range WM_APP through 0xBFFF. However in our codebase I often see that RegisterWindowMessage() is used for messages only sent w...

SetProcessWorkingSetSize usage

Has any one used SetProcessWorkingSetSize ? I am thinking of using it as my application runs out of Virtual Memory ? ...

About WM_MOUSEHOVER, controls and Balloons

Hi, I have this code in the switch (msg) loop inside WindowProc on my GUI App. case WM_MOUSEMOVE: TRACKMOUSEEVENT tme; tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.dwFlags = TME_HOVER; tme.dwHoverTime = 100; tme.hwndTrack = hwnd; TrackMouseEvent(&tme); break; case WM_MOUSEHOV...

How to make a named pipe not busy after client has disconnected?

I use a named pipe and I want to reuse the same pipe on the server to allow connecting another client once the original client has disconnected. What I do is: server creates a pipe using CreateNamedPipe server writes data using WriteFile, and retries doing so as long as error ERROR_PIPE_LISTENING is returned (which is before any client...

Screen capture ignores some windows

Hello, I am working in MFC and I am trying to capture a bmp of the desktop. I am using GetDC(NULL) to do this but it seems it ignores special skinned windows. It seems to ignore windows drawn with UpdateLayeredWindow. This behaviour seems to be happening only on Vista x64 and XP. I have also tried GetWindowDC with the desktop HWND but t...

Right side Explorer context menu (IID_IContextMenu?)

One of my applications has a Windows Explorer like file list control. When the user right clicks on a file I can successfully show the Explorer context menu (with some extra options of my own). However if the user right clicks on the list control itself (no items selected), then I'm unable to show the 'correct' context menu. I'd like to ...

RegisterEventSource method returning 'null' on Windows shutdown

I call RegisterEventSource() function during my service stop. But it is returning null during system shutdown. Is there any reason for this behavior? Error: I get error code 0x800706b5 on GetLastError() When googled, I came to know that it has something to do with missing registry data. Also, how to check if system shutdown has starte...

Which reasons could make ShellExecute fail?

I have a VB6 application which opens files with their associated application using: ShellExecute(0, "open", filename, params, vbNullString, vbNormalFocus) This works perfectly. Now I got a customer (running XP with Adobe Reader) who can't open any PDF file using the above command. But the same file is being opened without any proble...

Which one to use when static_cast and reinterpret_cast have the same effect?

Often, especially in Win32 programming it is required to cast from one opaque type to another. For example: HFONT font = cast_here<HFONT>( ::GetStockObject( SYSTEM_FONT ) ); Both static_cast and reinterpret_cast are applicable here and have exactly the same effect since HFONT is a pointer to a dummy struct specifically introduced for...

Is it possible to use AnimateWindow with AW_BLEND when using a layered window?

I am displaying a window using UpdateLayeredWindow and would like to add transition animations. AnimateWindow works if I use the slide or roll effects (though there is some flickering). However, when I try to use AW_BLEND to produce a fade effect, I not only lose any translucency after the animation (per-pixel and on the entire image), b...

compiling "standard" C++ in visual studio (non .net)

(This is a probably a very beginner question and I may be missing something obvious) I've just moved from my mac back to windows, and I'm trying to get set up with C++. I have visual studio 2008 C++: how do I compile "normal" non .net/clr C++? I want a command line application, and the only project that seemed fit was "CLR console appli...

Push / release button click

Hi all! I'm working on an windows application that requires separate events for the push and release of a button. While the button is pushed I have to rotate an opengl scene that is on a child window. I'd like to do that way in order so user doesn't have to make multiple button clicks each time he wants to rotate the scene. I've seen...

Running repetative method at specified moments (windows, .net etc) (like clock)

This is not an urgent nor important question, seems more like exercise. How to run a function at a specific moment? The more precise, the better. For instance, I have a method which says time. I want to run it on XX o'clock, XX:15:00 (and preferably, 000 ms), XX:30:00.000, XX:45:00.000. Currently I have an (almost endless) loop, which...

How do I use 'placeholder text' in a win32 edit control?

Take a look at the top-right of the Stack Overflow site. The search box has some text in it saying "search". When you click within it, the text disappears. I want to do something similar to this - if a win32 edit control is empty (i.e. has no text), I want to paint some text inside it, in a more subdued color than the normal text. If th...

GTK+ GTkStatusIcon not working in Win32

I cannot get GTkStatusIcon working in Windows and I get no errors. And I make a call to both gtk_status_icon_set_from_file and gtk_status_icon_new_from_file. Does anyone have any idea what could be causing this? I tried with .ico files and .png and still nothing... ...

Is there an equivelant to 'AssemblyInfo.cs' in a Win32 DLL project?

I already looked at this topic, but I need the answer flipped around. How would I set the assembly information attributes* in a Win32 DLL? ...

where to get the keycode for keyboard hook in c#

I am using the below code to disable the keyboard combination hooks. I got this code while i surfed the net. I want to know the list of keycodes for the keyboard keys. [lParam.vkCode == ???] Please provide me the link for that, Thanks.. namespace BlockShortcuts { public class DisableKeys { private delegate int LowLevelKeyboardProcDe...

Tkinter locks python when Icon loaded and tk.mainloop in a thread.

Here's the test case... import Tkinter as tk import thread from time import sleep if __name__ == '__main__': t = tk.Tk() thread.start_new_thread(t.mainloop, ()) # t.iconbitmap('icon.ico') b = tk.Button(text='test', command=exit) b.grid(row=0) while 1: sleep(1) This code works. Uncomment the t.iconbit...

Access to global data in a dll from an exported dll function

Hello, I am creating a C++ Win32 dll with some global data. There is a std::map defined globally and there are exported functions in the dll that write data into the map (after acquiring a write lock, ofcourse). My problem is, when I call the write function from inside the dll DllMain, it works without any problems. But when I load the...

Restart a process [exe] in Windows

I have a C++ exe; under a particular scenario I need to stop the exe and start it up again. This has to be done from within the same exe and not from outside. What is the best way to achieve this? My guess is to start a new instance of the process and then kill the running process. But is there any straight forward API to do this, like ...