0

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.

user1173240
  • 1,455
  • 2
  • 23
  • 50
  • `FindWindow()` API can give you the window handle whenever you want. You don't need to store a handle in registry. – liuyi.luo Jan 25 '13 at 05:08
  • The application which requires the Handle is like the second instance of the application. Looking at `FindWwindow()` , it uses the className and WindowName as parameters, so..isn't there some sort of ambiguity in prospect..? As two instances of the same application, with the same class name etc. are running. Kindly advise on this. And the parameters of `FIndMessage()` if I've understood them wrong... – user1173240 Jan 25 '13 at 05:53
  • Sounds like a bad design. The registry is for persistent information and the window handle is the exact opposite. Shared memory would be a more appropriate mechanism, or a named pipe. – MSalters Jan 25 '13 at 10:09

1 Answers1

0

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.

Superman
  • 3,027
  • 1
  • 15
  • 10