|
![]() |
![]() |
version 2003
PA_GetSerialKey → long
Parameter | Type | Description | ||||
This command does not require any parameters | ||||||
Function result | long | ← | Unique 4th Dimension number |
Description
The routine
PA_GetSerialKey
returns the unique ID of the 4D kernel serial number.
The plug-in can create its own serial number, based on the unique number returned by
PA_GetSerialKey
and check it at the
kInitiPlugin
event at startup.
The developer can also use the other information of this chapter to serialize its plug-in, linking it closer to one 4D application.
Example
Basic Serialization scheme.
Store the serial number in a preference file.
char gIsRegistered;
void PluginMain( long selector, PA_PluginParameters params )
{
switch ( selector )
{
case kInitPlugin :
gIsRegistered = IsRegistered();
if(!gIsRegistered)
gIsRegistered = RegisterMyPlugin();
break;
case kDeinitPlugin :
// enter some de-initialization code here if needed
break;
case 1 :
// enter code for first command here
break;
case 2 :
// enter code for second command here
break;
case 3 :
// enter code for third command here
break;
.
.
.
}
} // PluginMain
char IsRegistered()
{
long currentKey, thisKey;
// read the "old" key, stored in our prefs file
serialKey = ReadKeyFromPrefs();
// build a key for this app
thisKey = BuildSuperNumber(PA_GetSerialKey());
// Compare the 2 keys
return (char) currentKey == thisKey ? 1 : 0;
}
char RegisterMyPlugin ()
{
char sNum[256];
char result;
long thisKey, key;
// ask the user to entry the key
sNum[0] = (char) 0;
result = PA_Request("Enter the plug-in serial number:", sNum, "OK", "Cancel");
if(result && sNum[0])
{
MyStringToNum(sNum, key);
// build a key for this app
thisKey = BuildSuperNumber(PA_GetSerialKey());
// Compare both keys
result = (char) key == thisKey ? 1 : 0;
// OK, this is a good number -> save it in the prefs
if(result)
SaveKeyInPrefs(key);
}
return result;
}
See Also
PA_GetRegisteredUserCompany , PA_GetRegisteredUserName .
Error Handling
always returns
eER_NoErr