winapi

How to check if a NULL character is in a string when debugging with WinDbg

For instance: 0:000> ?? testFile //check this variable char * 0x009c6758 "e:\TEST\example.FOO" Question: How can I check for a NULL-terminated character in above? ...

Application Screen capture and rendering

I'm trying to write a simple app that will do a screen capture of an application and then rendering that capture in the 'main' application (ie, the application that took the screen capture). I've figured out how to get the window handle and get the application's screen capture, but I'm having trouble rendering the captured screen in th...

WM_NOTIFY and superclass chaining issue in Win32

For reference I'm using the window superclass method outlined in this article. The specific issue occurs if I want to handle WM_NOTIFY messages (i.e. for custom drawing) from the base control in the superclass I either need to reflect them back from the parent window or set my own window as the parent (passed inside CREATESTRUCT for WM_(...

What is the most efficient method to write data to the file?

I need to write a large amount of data in my application. Data arrive periodically and pushed into the queue. //producer queue_.push( new_data );// new_data is a 64kb memory range PostThreadMessage(worker_thread_id_, MyMsg, 0, 0);//notify the worker thread after that, i need to write this data to the file. I have another thread, that ...

Does someone have an optimized function to premultiply bitmap by alpha ?

GDIPlus blend functions use premultiplied rgb channel by alpha bitmaps for efficiency. However premultiplying by alpha is a very costly since you have to treat each pixel one by one. It seem that it would be a good candidate for SSE assembly. Is there someone here that would want to share its implementation? I know that this is hard wor...

Forwarding a Keystroke to another Control in WinForms

I am receiving a keystroke in a Form object's OnKeyDown. When some conditions are met (such as the keystroke is a printable character and not a hotkey) I want to forward the key to a text control on the form and set focus to the text control so the user can continue typing. I am able to decode the character typed using MapVirtualKey but ...

Good use of threads?

I have a set of operations that are very expensive but are all pretty much self-contained. Some of them rely on some "global" states or data, but all very much read-only. The operations themselves, I'm fairly certain, can all be done in parallel, but all the operations need to complete before the program progresses past a certain point. ...

SetThreadAffinityMask is ignored....any ideas?

Update: I found the problem - embarrassingly/ironically enough it was was calling SetThreadAffinity() in the wrong thread, not the main one (program startup is messy...) It's all working now, thanks for all the help! I've given everybody an upvote for taking part in my little debug session. ...

Custom form designer, move/resize controls using WinAPI

I have to fix some problems and enchance form designer written long ago for a database project. In Design Panel class code I encountered these lines private void DesignPanel_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { (sender as Control).Capture = false; switch (FMousePosition) ...

How to use WSAAsyncSelect from WinAPI in C#?

Hello, I'm tired of the .NET BeginRead,EndRead stuff.I'd love to use WSAAsyncSelect the way I used to in Delphi/C++ //Async CallBack handler Declaration procedure MessageHandler(var Msg:Tmessage);Message WM_WINSOCK_ASYNC_MSG; //Where i setup the Async dwError := WSAAsyncSelect(Sock, form1.handle, WM_WINSOCK_ASYNC_MSG, FD_CLOSE or FD_R...

Can i make a DLL file auto run and keep working?

I just saw in some wordpress plugins, there are auto tag plugin, auto RSS fetch, just you install the plugin and it keep working for ever without calling it. What i want to do is to put a dll file inside my Images folder and it will monitor the uploaded files and edit them based on some options, i want this dll to work automatically just...

How does software like Spy++ get the information ?

I'm working on a software for test automation. To get it working it need's to "have a look" on the desktop and all open windows. It needs to know which windows are open and what controls they consist of. So it has to do something similar to what Spy++ is doing (Spy++ from Visual Studio). Does anyone know how Spy ++ get's all the informat...

How is Win32 event-driven programming implemented under the hood?

In a Win32 C++ application, we start a message loop that fetches messages from a queue, translates them and then dispatches them. Eventually, each message reaches our WndProc where the associated event can be handled. I understand that part. What I don't understand is the in between goings-on. Specifically: Different kinds of OS inter...

C#: How to get last error(WSAGetLastError)?

Hello, How do I call WSAGetLastError() from WinAPI so I get the valid text error? ...

Representation of wchar_t and char in WinDbg

Note: /* * Trivial code */ wchar_t *greeting = L"Hello World!"; char *greeting_ = "Hello World!"; WinDbg: 0:000> ?? greeting wchar_t * 0x00415810 "Hello World!" 0:000> ?? greeting_ char * 0x00415800 "Hello World!" 0:000> db 0x00415800 00415800 48 65 6c 6c 6f 20 57 6f-72 6c 64 21 00 00 00 00 Hello World!.... 00415810 48 00 65 00 6...

Detect a VGA monitor on windows, using DDC?

Does windows provide any api calls to detect if a monitor is presently connected on the VGA port by using DDC I or DCC 2? I am trying to figure out a way to know if a monitor is connected and turned on. ...

Detect if desktop is locked

What is the best way to determine if the desktop is locked for the currently logged in user? I looked in MSDN and couldn't find any API calls to detect this. Did I miss something, or is there no simple call I can use? ...

Why does my Visual Studio Win32 project require .net 3.5 sp1 to install?

Using Visual Studio 2008, I created a c++ Win32 project. To release the program, I made a visual studio setup project within the same solution. The setup.exe prompts my users to install .Net 3.5 SP1, which is often a 15+ minute install and only allowed to administrator level accounts. If they do not there is an error along the lines o...

non-unicode WM_CHAR in unicode windows

I have written a DLL which exports a function that creates a window using RegisterClassExW and CreateWindowExW. Every message is retrieved via GetMessageW(&msg, wnd_handle, 0, 0); TranslateMessage(&msg); DispatchMessageW(&msg); Also there is a program which loads the DLL and calls the function. Despite the Unicode window creation m...

How to properly use structs inside a class?

Using: VS2008, Win32, C/C++ I'm trying to encapsulate my entire dialog window into a class for reusability. Sort of like a custom control. In doing this, I am moving my seperate functions into a class. The following struct design though is giving me problems, with Visual Studio outputting: error C2334 '{'. It's a simple message map ...