Side effects of calling RegisterWindow multiple times with the same window class?

I have been working on a small test application for a minute, and I have several window objects floating around, and each of them calls RegisterWindowEx with the same WNDCLASSEX structure (mainly because they are all instances of the same class).

The first one is registered in order, then several of them fail, saying that the class is already registered - as expected.

My question is this bad? I was thinking of using a hash table to store the ATOM results to look before calling RegisterWindow, but it looks like Windows is already doing this?

+3
source share
5 answers
+3

DLL

, RegisterClass() PROCESS_ATTACH DllMain UnregisterClass() PROCESS_DETACH DllMain

, RegisterClass() , UnregisterClass() .

, , . , ... , ...

, , , .

/DllMain?

- ( , ). " ", , DllMain.

?

Windows , .

GetClassInfo(), , .

Windows ( , ).

, Windows , . MSDN ( ... ).

?

, , . , Win32 , . .

+4

RegisterWindowEx, ATOM . ATOM .

+2

, ​​- RegisterClass, , - - , , .

, , , . , -, , , .

0

. , , , RegisterClass(). ERROR_CLASS_ALREADY_EXISTS UnregisterClass() dtor, 0.

( InterlockedIncrement() InterlockedDecrement() ) , , .

0

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


All Articles