procedure TSmartCard.SetActive(Value: Boolean);
var
C,L,I: LongInt;
S: AnsiString;
begin
if Value = FActive
then exit;
try SetCursor (LoadCursor (0, IDC_WAIT));
if Value
then begin
if FLibHandle > 0
then FreeLibrary(FLibHandle);
FLibHandle:=2;
FLibHandle:=LoadLibrary(DllFile);
if FLibHandle < HINSTANCE_ERROR
then
Error('
Invalid/missing SmartCard library '+ DllFile +
'
(Error code '+IntToStr(FLibHandle)+'
)'+#13#10+
'
Pls. download latest version at: http://www.towitoko.de');
{$IFDEF SCARDDIR}
FSCardComand:=SCardComand;
{$ELSE}
@FSCardComand:=GetProcAddress(FLibHandle, '
SCardComand');
{$ENDIF}
if not Assigned(FSCardComand)
then begin
FreeLibrary(FLibHandle);
FLibHandle:=0;
Error('
Invalid SmartCard library '+StrPas(PAnsiChar(@DllFile[1]))+
'
(version mismatch)'+#13#10+
'
Pls. download latest version at: http://www.towitoko.de');
end;
FTDevHandle:=0;
L:=-1; C:=0;
S:=cmSystem+cmAddHWndMsg+
IntToStr(FWindowHandle)+'
,'+IntToStr(TDEVMSG)+#0;
I:=FSCardComand(L,@S[1],C,
nil,C,
nil,C);
if (I > 0)
or (L <= 0)
then begin
FreeLibrary(FLibHandle);
FLibHandle:=0;
Error('
Cannot access SmartCard Server: '+IntToHex(I,4));
end;
FTDevHandle:=L;
FActive:=True;
GetDeviceList;
InsertMenuItems;
end else begin
try Comand(cmSystem+cmDelHWnd+IntToStr(FWindowHandle),
nil,0,
nil,0);
except end;
try Comand(cmSystem+cmDestroy,
nil,0,
nil,0);
except end;
FreeLibrary(FLibHandle);
FLibHandle:=0;
FActive:=False;
end;
finally Screen.Cursor:=crDefault;
end;
end;