Protection API - SDP_GetExpirationDate


SDP_GetExpirationDate

The SDP_GetExpirationDate function is used to read in expiration date.

  For C++:

        int SDP_GetExpirationDate( LPSYSTEMTIME lpSystemTime // expiration date
);

  For Delphi:   

function SDP_GetExpirationDate(
lpSystemTime :PSystemTime // expiration date ): Integer;

Parameters
lpSystemTime

[out] Pointer to a SYSTEMTIME structure to receive expiration date.

Return Values
If the function succeeds, the return value is 1.

if trial period has expired, the return value is -1.

If the function fails, the return value is zero.

Remarks
Be aware, if you use two (or three) of "Number of days" , "Number of executions" and "Expiration Date" parameters in "Trial Info" Tab, one of them has expired means trial period has expired. For instance, if you both set "Expiration Date" and "Number of executions" parameters, and only number of executions has expired, if you call SDP_GetExpirationDate, you will get return value of -1 even if current time is still ahead of expiration date.

the cause of function fail can be invalid trial count data is stored in user's computer, or you do not set expiration date in "Trial Info" Tab.
Example
for C++

#include "SDProtector.h"
//...
void GetExpirationDate() { SYSTEMTIME ExpirationDate; char szInfo[256]; int =iResult; iResult=SDP_GetExpirationDate(&ExpirationDate); if(iResult==1) { //If succeeded sprintf(szInfo,"This program will be expired on %4d,%02d,%02d", ExpirationDate.wYear,ExpirationDate.wMonth,ExpirationDate.wDay);
::MessageBox(NULL,szInfo,"Expiration Info",MB_ICONINFORMATION);
} else if(iResult==-1) { //if expired ::MessageBox(NULL,"Sorry, you trial period has expired","Error",MB_ICONINFORMATION); } else { //if failed ::MessageBox(NULL,"Get expiration date error","Error",MB_ICONINFORMATION); }

}

for Delphi

        
procedure GetExpirationDate;
var ExpirationDate: SYSTEMTIME;
szInfo: String; iResult:Integer; begin iResult:=SDP_GetExpirationDate(@ExpirationDate); if iResult= 1 then begin szInfo=format('this program will be expired on %4d,%02d,%02d',
[ExpirationDate.wYear,ExpirationDate.wMonth,ExpirationDate.wDay]); MessageBox(0,@szInfo[1],'Expiration Info', MB_ICONINFORMATION); end else if iResult= -1 then MessageBox(0,'Sorry, you trial period has expired','Error',MB_ICONINFORMATION) else MessageBox(0,'Get expiration date error','Error',MB_ICONINFORMATION); end;
Sample application is located in \Examples\Delphi\API\ and \Examples\VC\API\ directory.
 
CopyRight(C) 2003 SDProtector.com All Rights Reserved