uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleServer, WINSATLib_TLB, StdCtrls,comobj, ComCtrls,
activex, ExtCtrls ;
Type TMyCallback =
class (TComObject,IWInSatInitiateEvents)
function WinSATComplete(hresult: HResult; strDescription: PWideChar): HResult;
stdcall;
function WinSATUpdate(uCurrentTick: longword; uTickTotal: longword; strCurrentState: PWideChar): HResult;
stdcall;
constructor Create;
end;
var
Form2: TForm2;
i:IWinSATInitiateEvents;
k:_RemotableHandle;
progresposition:integer;
icurrent,itotal:longword;
t:tmycallback;
sa:
string;
function TMyCallback.WinSATComplete(hresult: HResult; strDescription: PWideChar): HResult;
stdcall;
begin
if Succeeded(hresult)
then result:=strtoint(strDescription)
else showmessage(strDescription);
end;
function TMyCallback.WinSATUpdate(uCurrentTick: longword; uTickTotal: longword; strCurrentState: PWideChar): HResult;
stdcall;
var
Assesment:^IInitiateWinSATAssessment;
hr:HRESULT;
begin
if uticktotal>0
then begin
progresposition:=100*ucurrentTick
div utickTotal;
result:=s_ok;
Assesment:=nil;
CoInitializeEx(
nil, COINIT_APARTMENTTHREADED);
OleCheck(CoCreateInstance(
Class_CInitiateWinSAT,
nil,
CLSCTX_INPROC_SERVER,
IInitiateWinSATAssessment,
Assesment));
if FAILED(hr)
then
showmessage('
Failed to create an instance of IInitiateWinSATAssessment. Failed with ');
end;
end;