Results 1 to 4 of 4

Thread: What exactly does RegisterWindowMessage do?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    What exactly does RegisterWindowMessage do?

    Does it add the string that's the input parameter to some entry in the Windows Registry (as hinted at by the fact it is called REGISTER window message, instead of STORE window message or SAVE window message), that can later for example be viewed in RegEdit? Or does it store it somewhere else? Wherever it stores it, when it is no longer needed, how do I reliably clean up the leftover files / registry entries that this API function leaves behind?

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: What exactly does RegisterWindowMessage do?

    I believe the "Register" in the RegisterWindowMessage function has nothing to do with the Windows Registry at all. According to Raymond Chen's blog article Some other places atoms (and the magical 0xC000) arise:

    Quote Originally Posted by Raymond Chen
    I'll start with registered window messages, created by the RegisterWindowMessage function. These are not officially atoms; they are just integers that happen to lie in the range 0xC000 to 0xFFFF, just like atoms. But yeah, internally, they're atoms. Of course, you shouldn't rely on it since it's not contractual. Think of it as a fantastic coincidence.
    Based on the discussion here, registered window messages are probably stored in a system-maintained Local Atom Table.

    There's no need to clean up anything because "The message remains registered until the session ends." According again to Raymond:

    Quote Originally Posted by Raymond Chen
    Registered window messages cannot be freed; once they've been created they will hang around until you log off.
    Last edited by Bonnie West; Dec 16th, 2014 at 07:01 PM. Reason: Added "According again..."
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: What exactly does RegisterWindowMessage do?

    Quote Originally Posted by Bonnie West View Post
    I believe the "Register" in the RegisterWindowMessage function has nothing to do with the Windows Registry at all. According to Raymond Chen's blog article Some other places atoms (and the magical 0xC000) arise:



    Based on the discussion here, registered window messages are probably stored in a system-maintained Local Atom Table.

    There's no need to clean up anything because "The message remains registered until the session ends." According again to Raymond:

    So your session is as long as the program that registered the window "message" is running? Or does it refer to your Windows session (requiring you to reboot your computer to clear the registered message)?

  4. #4
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: What exactly does RegisterWindowMessage do?

    The session usually refers to the session of the user who launched the program that registered the window message. It will remain registered until that user logs off, not when the system shuts down.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width