Protection API - SDP_GetNumOfDaysLeft


SDP_GetNumOfDaysLeft

The SDP_GetNumOfDaysLeft function is used to obains the number of days remaining in the trial period.

  For C++:

        int SDP_GetNumOfDaysLeft( LPDWORD lpdwNum //disposition value buffer
);

  For Delphi:

       function SDP_GetNumOfDaysLeft(
lpdwNum :PDWORD
// disposition value buffer ): Integer;

Parameters
lpdwNum

[out] Pointer to a variable that receives the number of days remaining in the trial period

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 "Number of days" and "Number of executions" parameters, and only number of executions has expired, if you call SDP_GetNumOfDaysLeft, you will get return value of -1 even if number of days remaining in the trial period is not zero.

the cause of function fail can be you do not set "Number of days" parameters in "Trial Info" Tab.
Example
for C/C++

#include "SDProtector.h"
//...
void GetExecs() { DWORD dNumofDays; char szInfo[256]; int iResult;

iResult=SDP_GetNumOfDaysLeft(&dNumofDays);
if(iResult==1)
{
//If succeeded
sprintf(szInfo,"you have %d day(s) left",dNumofDays);
::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 number Of days error","Error",MB_ICONINFORMATION); } }

for Delphi

        
procedure GetExpirationDate;
var dNumofDays: LongWord;
szInfo: String;
iResult:Integer;
begin
iResult:=SDP_GetNumOfDaysLeft(@dNumofDays);
if iResult= 1 then
begin
szInfo=format('you have %d day(s) left',[dNumofDays]);
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 number Of days 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