Message processing in console applications / DLL in C ++ Win32

I would like to be able to process Win32 messages in a console application and / or inside a standalone DLL.

I was able to do this in .NET with the next article, and it works fine in C # inside the console application and the standalone DLL
http://msdn.microsoft.com/en-us/magazine/cc163417.aspx

Is there a way to make an equivalent with the C / C ++ Win32 API? I tried doing RegisterClassEx (...) and CreateWindow (...), even passing HWND_MESSAGE to hWndParent, but the problem is that messages are not processed after creating the "invisible" window, probably due to the lack of a message.

Where will the message pump work if you have an entry point to the DLL? I tried to create another thread in the DLL and put while (GetMesage (..)), but that didn't work either.

Any ideas?

+3
source share
2 answers

You need a message pump yes. The window also has a thread similarity, so it must be created in the same thread on which the message pump is running. The basic approach sounds if you include more code, it may be clear what the problem is.

+2
source

In addition to what Logan Capaldo said, you also have a problem that, like a DLL, at compile time you don’t know which process will load you at runtime.

+2

Source: https://habr.com/ru/post/1742608/


All Articles