|
|
LicenceNotFoundHandlerProc |
The LicenceNotFoundHandlerProc function is an application-defined callback function that can be called if the program licence cannot be found. This callback function is specified by calling C_RegisterLicenceNotFoundHandler.
void __stdcall LicenceNotFoundHandlerProc(
int Action,
BOOL *lpAttemptReconnection,
INT_PTR *lpData
);
An integer value that identifies the current stage of the licence reconnection. Can be one of the following values: lrBegin, lrContinue or lrEnd.
Points to a BOOL variable which determines whether reconnection should be attempted – set this BOOL variable non-zero to attempt reconnection.
Points to an application defined value that can be used to maintain state between successive invocations of the callback function. Typically the callback function would assign a value to *lpData when handling the lrBegin action. This value could then be used in subsequent lrContinue actions. If any tidy up is needed that would be performed when handling lrEnd.
If a callback function is registered, and the licence cannot be found, then the callback function is called in the following sequence:
lrBegin action. If *lpAttemptReconnection is non-zero when the callback returns, then the program attempts to reconnect to the licence. Otherwise no attempt to reconnect is made.lrContinue action. Again, the value of *lpAttemptReconnection is used to indicate whether or not the program should attempt to reconnect. Repeated calls with the lrContinue action are made until either reconnection succeeds, or *lpAttemptReconnection is set to zero.lrEnd action. This would typically be used to deallocate any memory allocated in previous calls and held in *lpData. The value of *lpAttemptReconnection can be used to determine whether or not reconnection succeeded. This value is simply the value returned by the most recent invocation of the callback. Hence, a zero value indicates that reconnection was not attempted in the prior step, and so reconnection failed. A non-zero step indicates that reconnection was attempted in the prior step, and succeeded.As an example of how this callback might be implemented, this function attempts to reconnect every minute and gives up after 10 attempts.
void __stdcall LicenceNotFoundHandlerProc(int Action, BOOL *lpAttemptReconnection, INT_PTR *lpData)
{
switch (Action)
{
case lrBegin:
Sleep(60*1000); // wait for a minute
*lpAttemptReconnection = TRUE;
*lpData = 1; // initialise reconnection attempt count
return;
case lrContinue:
*lpAttemptReconnection = *lpData < 10; // stop after 10 failures
*lpData++; // increment reconnection count
if (*lpAttemptReconnection)
Sleep(60*1000); // wait for a minute
return;
case lrEnd:
; // nothing to do, test *lpAttemptReconnection to determine whether connection succeeded
}
}