To install a component, setup application need to:
- Copy DLL/Shared object file to its final location.
- Register it as a COM server object. This could be done, as usual, by loading DLL/Shared object and calling its DllRegisterServer exported function.
To uninstall a component, application need to call DllUnregisterServer and then delete the file itself.
These procedures are very similar to registration procedure descibed below.
To learn more, please, refer to any COM programming manual.
Component registration process is quite simple. To register a component, external software should make the following steps:
- Load component as DLL/Shared object - not as a COM object.
- Find "RegNow" exported function address.
- Fill special RegUserData structure with registration information.
- Call the function and analyse results.
There will be declarations and examples in C.
All necessary declarations are provided below:
#define REGFNSIZE 40
#define REGLNSIZE 40
#define REGKEYSIZE 64
struct RegUserData {
char first_name[REGFNSIZE+1];
char last_name[REGLNSIZE+1];
char key[REGKEYSIZE+1];
};
long RegNow(RegUserData *);
typedef long (*regfun)(RegUserData *);
#define REGISTER_ERROR 0
#define REGISTER_UNLIMITED -1
If function will fail, it will return REGISTER_ERROR (0).
Otherwise, it will return number of site licenses. Special case is unlimited number of lite licenses - REGISTER_UNLIMITED (-1).
This example does not contain necessary error checking so it should not be used as-is.
HINSTANCE han=LoadLibrary(dllname);
regfun fn=(regfun)GetProcAddress(han,"RegNow");
RegUserData RUD;
strcpy(RUD.first_name,first_name);
strcpy(RUD.last_name,last_name);
strcpy(RUD.key,key);
long NumLic=fn(&RUD);
if(!NumLic) {
MessageBox(NULL,_TEXT("Component was not registered. Invalid user names or keycode.\n"),_TEXT(""),MB_OK);
FreeLibrary(han);
} else {
if (NumLic == -1){
MessageBox(NULL,_TEXT("Component successfully registered.\nUnlimited sites license\n"),_TEXT(""),MB_OK);
} else {
CString temp;
temp.Format(_TEXT("Component successfully registered.\nNumber of site licenses: %lu\n"),NumLic);
MessageBox(NULL,temp,_TEXT(""),MB_OK);
}
}
FreeLibrary(han);
This example does not contain necessary error checking so it should not be used as-is.
void *han=dlopen((char *)dllname,RTLD_NOW);
regfun fn=(regfun)dlsym(han,"RegNow");
RegUserData RUD;
strcpy(RUD.first_name,first_name);
strcpy(RUD.last_name,last_name);
strcpy(RUD.key,key);
long NumLic=fn(&RUD);
if(!NumLic) {
printf("Component was not registered. Invalid user names or keycode.\n");
dlclose(han);
} else {
if (NumLic == -1){
printf("Component successfully registered.\nUnlimited sites license\n");
} else {
printf("Component %s successfully registered.\nNumber of site licenses: %lu\n");
}
}
dlclose(han);