Search code examples
c++qtwindow-handles

Storing and using Windows Handle ( WId ) in registry


I wish to store the Window handle of a running instance of an application in the registry, the WId of a widget ( in Qt ).

I need this to ensure that if another application starts, it can check the registry to know whom it is supposed to send a message to, using sendMessage() windows API.

How do I achieve this?

The type of a Windows handle , HWND, of which WId is a typedef..is a void pointer.

How do I store information of this type in a registry setting, and then retrieve to use it again?

Please help me with this. I’ll be obliged. Thanks.


Solution

  • Depending on the bitness of the your program you can either use REG_DWORD for 32-bit programs or REG_QWORD for 64-bit programs.