Delphi 쓰기 웹 보안 컨트롤(dll,ocx)

2051 단어 Delphi
unit Unt_Machine_WebDll;

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
  ComObj, ActiveX, Machine_TLB, StdVcl, SysUtils, Windows, Device ;

const
  g_SupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER or INTERFACESAFE_FOR_UNTRUSTED_DATA ;

type
  TMachine = class(TAutoObject, IMachine, IObjectSafety)
  private
    FObjectSafetyFlags: DWORD;
  protected
    { Protected declarations }
      ...
  public
    { IObjectSafety }
    function GetInterfaceSafetyOptions(const IID: TIID; pdwSupportedOptions,
      pdwEnabledOptions: PDWORD): HResult; virtual; stdcall;
    function SetInterfaceSafetyOptions(const IID: TIID; dwOptionSetMask,
      dwEnabledOptions: DWORD): HResult; virtual; stdcall;
  end;

implementation

uses ComServ;

/////////////    /////////////////////////////////////////
var
   ...

function TMachine.GetInterfaceSafetyOptions(const IID: TIID;
  pdwSupportedOptions, pdwEnabledOptions: PDWORD): HResult;
var
  Unk: IUnknown;
begin
  if (pdwSupportedOptions = nil) or (pdwEnabledOptions = nil) then
  begin
    Result := E_POINTER;
    Exit;
  end;
  Result := QueryInterface(IID, Unk);
  if Result = S_OK then
  begin
    pdwSupportedOptions^ := INTERFACESAFE_FOR_UNTRUSTED_CALLER or
      INTERFACESAFE_FOR_UNTRUSTED_DATA;
    pdwEnabledOptions^ := FObjectSafetyFlags and
      (INTERFACESAFE_FOR_UNTRUSTED_CALLER or INTERFACESAFE_FOR_UNTRUSTED_DATA);
  end
  else begin
    pdwSupportedOptions^ := 0;
    pdwEnabledOptions^ := 0;
  end;    
end;

function TMachine.SetInterfaceSafetyOptions(const IID: TIID;
  dwOptionSetMask, dwEnabledOptions: DWORD): HResult;
var
  Unk: IUnknown;
begin
  Result := QueryInterface(IID, Unk);
  if Result <> S_OK then Exit;
  FObjectSafetyFlags := dwEnabledOptions and dwOptionSetMask;
end;


initialization
  TAutoObjectFactory.Create(ComServer, TMachine, Class_Machine,
    ciMultiInstance, tmApartment);
end.


좋은 웹페이지 즐겨찾기