winapi

Getting an event on monitor hotplug for windows

I'd really like to listen for when a monitor gets hotplugged like when a laptop docs or has a external monitor plugged in. I'm hoping I can do this in .net maybe with some pinvoke. ...

Strange compiler errors with code::blocks

I switched from Visual Studio to Code::Blocks yesterday, and just had some strange compiler error messages. I included windows.h and i can use all the API calls just fine, such as creating window classes and creating windows / buttons and stuff. But when I tried to send some keypresses with SendInput(), I got error messages on these two...

OK to copy a CRITICAL_SECTION?

One can use a CRITICAL_SECTION variable to get mutual exclusion. My question is: does CRITICAL_SECTION support copying? If I pass one by value to another thread, can I know for sure that mutual exclusion will work? I wouldn't be surprised if the answer is "you cannot do that", but it'd be nice to have some sort of official confirmati...

Sending mouse events to another windows, C# under Win 7

Is there a way to send mouse events to another window in Window 7 ? I used to do this : [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo); But this does not seem to work anymore in ...

How should I understand these PHP errors?

This is out of the error log: PHP Warning: PHP Startup: BOPEE Extension: Unable to initialize module Module compiled with build ID=API20090626,TS,VC9 PHP compiled with build ID=API20090626,NTS,VC9 These options need to match in Unknown on line 0 PHP Warning: PHP Startup: CustomExt Module: Unable to initialize module Module compile...

How to check if file was changed since it was last read from? (C#)

I have a text file that several instances of the same app use to synchronize and exchange data between themselves. In a nutshell it's a plain text file that contains list of data files. These data files come and go on a regular basis. Is there a reliable way to know that some app wrote to the file since it was last read from? Normally y...

Wrapping msctls_hotkey32 in .NET Windows Forms

Hi all. I'm trying to get a hotkey control working in C# based on both the Control class and the msctls_hotkey32 win32 class. What I have works, though it's not perfect: class Hotkey : TextBox { protected override CreateParams CreateParams { get { CreateParams parms = base....

Problems with using TrackPopupMenu on win7

I'm trying to create context menu using TrackPopupMenu function in my application, the code I use in it is like the following: CMenu menu; if (menu.LoadMenu(IDR_MENU_TRAY)) { CMenu* pSubMenu = menu.GetSubMenu(0); if (pSubMenu != NULL) { pSubMenu->ModifyMenu(IDM_CLOSE,MF...

USB serial verification in C++

Hi, I have a DLL which I intend to send to a 3rd party and I'd like to protect it by restricting it to run only if a specific USB device is connected. I'm using the setupapi to get the device's serial number (by calling SetupDiGetDeviceInstanceId()). I would like to make the verification hard to track in case someone disassembles the DL...

Information sought on filesystems and high-performance memory-mapped data stores on Windows

I've recently acquired responsibility for a critical system which is a data store featuring memory-mapped IO, multi-threaded (local) clients, and an interesting mixture of constraints. It has to store a mix of serial and indexed data including sparse 3D data of varying levels of detail. Performance is critical, including being able to w...

Proper way of passing a pointer for P/Invoke function.

Dear skilled. I’m developing an entity which allows user to copy multiple files in async manner with cancellation ability (and reporting progress as well). Obviously the process of copying runs in another thread, different from thread where CopyAsync was called. My first implementation uses FileStream.BeginRead/BeginWrite with a buffer ...

Determine if a directory can be moved on NTFS

I have a directory that contains lots of files in a complex tree of sub-directories. If I try to move that directory into a another directory on the same partition, that operation could theoretically take constant time - a rename operation, basically. - as long as none of the files in the source directory are in use and there are no sec...

Terminal Widget for MFC/Win32 applications?

I need a terminal Widget which is able to emulate a windows console and a simple VT100 terminal on Windows. Something like VTE for GTK or QConsole for QT. Is it even possible to run a Windows Console like cmd.exe inside a child window? ...

Disable Window Resizing Win32

how do I disable resizing by dragging the edge of windows? Here is my window creation code bool CreateGLWindow(char* title, int width, int height) { GLuint PixelFormat; // Holds The Results After Searching For A Match WNDCLASS wc; // Windows Class Structure DWORD dwExStyle; // W...

How can I force Windows to clear all disk read cache data?

I'm writing a disk intensive win32 program. The first time it runs, it runs a lot slower while it scans the user's folders using FindFirstFile()/FindNextFile(). How can I repeat this first time performance without rebooting? Is there any way to force the system to discard everything in its disk cache? I know that if I were reading a si...

Reliable way to wait for another Windows process to redraw its main window

I am moving a window (belonging to another process) to the front in order to take a screenshot of it. I am able to do this using SetForegroundWindow, however that function returns immediately. The other process takes a varying amount of time to redraw its main window (which requires it to access a database) so I cannot be sure that whe...

Windows design and implementation using classes

Are there any good books that will teach you about creating windows applications using classes? ...

Modeless Child Dialog

I'm creating modeless child dialogs from a parent dialog class and i want to share the class data of its parent window with all child dialog classes I'll be creating. how would i go do that? ...

C++ WinAPI: handling long file paths/names

I'm looking at handling longer file paths in my windows application. Currently, I have a text box (edit box) in which a user can type an absolute file path. I then read that typed file path, using GetWindowText, into a string declared like so: TCHAR FilePath[MAX_PATH]; Obviously, here i'm relying on the MAX_PATH constant which limits m...

Hook a QT Application with C++ to capture textname of the application

Hi guys, I have a simple QT application running on Win32 platform. I need to write a C++ program described as: the input is the windows handle of that QT application, which is already available, the output is the text name ( AKA caption ) of the application. I hope someone will show me the way to do this right. Thanks a lot. Smile ...