Page 1 of 1

RegisterApplication() & UnregisterApplication()

Posted: Sun Jul 06, 2014 1:38 pm
by javierdlr
Hi, just added some Printf's to Mixer code and found that when RegisterApplication() & UnregisterApplication() the appID I get next time I execute Mixer it increases +1 the previous appID.
As I UnregisterApplication(), shouldn't next time the same appID be used, as it is "disposed"/freed by UnregisterApplication()?

Piece of code I use in RegisterApplication():
Hidden Text - Click to Show :

Code: Select all

...
 if(WBenchMsg)
  appID = IApplication->RegisterApplication(IDOS->FilePart(mixerfullpath),
                         REGAPP_WBStartup, (ULONG)WBenchMsg,
                         REGAPP_Description, GetString(&li, MSG_COMMODITY),
                         REGAPP_Hidden, !cxPopup,
                         REGAPP_HasIconifyFeature, TRUE,
                         REGAPP_UniqueApplication, TRUE,
                         REGAPP_AppIconInfo, (ULONG)&aii,
                        TAG_DONE);
 else
  appID = IApplication->RegisterApplication(IDOS->FilePart(mixerfullpath),
                         REGAPP_FileName, mixerfullpath,
                         REGAPP_Description, GetString(&li, MSG_COMMODITY),
                         REGAPP_Hidden, !cxPopup,
                         REGAPP_HasIconifyFeature, TRUE,
                         REGAPP_UniqueApplication, TRUE,
                         REGAPP_AppIconInfo, (ULONG)&aii,
                        TAG_DONE);
...
Or maybe is 'REGAPP_UniqueApplication, TRUE' feature?


1)run Mixer for first time:
START create_docky()
appID=0x00000000 'Utilidades:MUSICA/Mixer/Mixer' WBenchMsg=0x57415AC2 cxPopup=1 aii=0x5917CBB8
RegisterApplication(): appID=0x0000000F
AppDocky='Mixer' applibPort=0x5D56D810
END create_docky()
...
2)quit Mixer:
...
UnregisterApplication(): appID=0x0000000F

3)Re-execute Mixer again:
START create_docky()
appID=0x00000000 'Utilidades:MUSICA/Mixer/Mixer' WBenchMsg=0x57415982 cxPopup=1 aii=0x5917CBB8
RegisterApplication(): appID=0x00000010
AppDocky='Mixer' applibPort=0x5D56DB10
END create_docky()
...

Re: RegisterApplication() & UnregisterApplication()

Posted: Sun Jul 06, 2014 6:08 pm
by LyleHaze
From the application autodoc, RegisterApplicationA, Results:

appID - 0 if application registration failed, otherwise an
application ID (== handle) is returned.
An application ID is always unique and is guaranteed to be
*notreused after an application unregistered itself.


;)

The "REGAPP_UniqueApplication" will cause the registration to fail if another instance of the same app is already running.

Re: RegisterApplication() & UnregisterApplication()

Posted: Sun Jul 06, 2014 7:20 pm
by javierdlr
LyleHaze wrote:From the application autodoc, RegisterApplicationA, Results:

appID - 0 if application registration failed, otherwise an
application ID (== handle) is returned.
An application ID is always unique and is guaranteed to be
notreused after an application unregistered itself.
Ooops thx, didn't read that part of autodoc :-)

Re: RegisterApplication() & UnregisterApplication()

Posted: Sat Jul 12, 2014 1:20 pm
by trixie
@javierdlr
As I UnregisterApplication(), shouldn't next time the same appID be used, as it is "disposed"/freed by UnregisterApplication()?
No. AppIDs are assigned incrementally with each RegisterApplication(), and are never reused until reboot. This is to prevent applications from possibly talking to "the wrong addressee". Imagine that as part of a routine, "App 1" repeatedly calls SendApplicationMsg() to communicate with "App 2". Now if "App 2" unregistered and its appID got reused, "App 1" would suddenly send messages to an app that doesn't expect them.