[541] | 1 | //*************************************************************
|
---|
| 2 | // EwbClasses *
|
---|
| 3 | // *
|
---|
| 4 | // Freeware unit *
|
---|
| 5 | // For Delphi 5 - 2009 *
|
---|
| 6 | // by *
|
---|
| 7 | // Serge Voloshenyuk *
|
---|
| 8 | // Developing Team: *
|
---|
| 9 | // Serge Voloshenyuk (SergeV@bsalsa.com) *
|
---|
| 10 | // Eran Bodankin (bsalsa) -(bsalsa@gmail.com) *
|
---|
| 11 | // *
|
---|
| 12 | // Documentation and updated versions: *
|
---|
| 13 | // *
|
---|
| 14 | // http://www.bsalsa.com *
|
---|
| 15 | //*************************************************************
|
---|
| 16 | {LICENSE:
|
---|
| 17 | THIS SOFTWARE IS PROVIDED TO YOU "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
---|
| 18 | EITHER EXPRESSED OR IMPLIED INCLUDING BUT NOT LIMITED TO THE APPLIED
|
---|
| 19 | WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
---|
| 20 | YOU ASSUME THE ENTIRE RISK AS TO THE ACCURACY AND THE USE OF THE SOFTWARE
|
---|
| 21 | AND ALL OTHER RISK ARISING OUT OF THE USE OR PERFORMANCE OF THIS SOFTWARE
|
---|
| 22 | AND DOCUMENTATION. BSALSA PRODUCTIONS DOES NOT WARRANT THAT THE SOFTWARE IS ERROR-FREE
|
---|
| 23 | OR WILL OPERATE WITHOUT INTERRUPTION. THE SOFTWARE IS NOT DESIGNED, INTENDED
|
---|
| 24 | OR LICENSED FOR USE IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE CONTROLS,
|
---|
| 25 | INCLUDING WITHOUT LIMITATION, THE DESIGN, CONSTRUCTION, MAINTENANCE OR
|
---|
| 26 | OPERATION OF NUCLEAR FACILITIES, AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS,
|
---|
| 27 | AIR TRAFFIC CONTROL, AND LIFE SUPPORT OR WEAPONS SYSTEMS. BSALSA PRODUCTIONS SPECIFICALLY
|
---|
| 28 | DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR SUCH PURPOSE.
|
---|
| 29 |
|
---|
| 30 | You may use/ change/ modify the component under 3 conditions:
|
---|
| 31 | 1. In your website, add a link to "http://www.bsalsa.com"
|
---|
| 32 | 2. In your application, add credits to "Embedded Web Browser"
|
---|
| 33 | 3. Mail me (bsalsa@gmail.com) any code change in the unit for the benefit
|
---|
| 34 | of the other users.
|
---|
| 35 | 4. Please, consider donation in our web site!
|
---|
| 36 | {*******************************************************************************}
|
---|
| 37 | //$Id: EwbClasses.pas,v 1.1.2.1 2006/11/29 22:13:01 sergev Exp $
|
---|
| 38 |
|
---|
| 39 | unit EwbClasses;
|
---|
| 40 |
|
---|
| 41 | interface
|
---|
| 42 |
|
---|
| 43 | {$I EWB.inc}
|
---|
| 44 |
|
---|
| 45 | uses
|
---|
| 46 | Windows;
|
---|
| 47 |
|
---|
| 48 | type
|
---|
| 49 | IInterfaceObjectReference = interface
|
---|
| 50 | ['{C0D28425-8410-45F6-BD60-8AE66782E545}']
|
---|
| 51 | function GetObject: TObject;
|
---|
| 52 | end;
|
---|
| 53 |
|
---|
| 54 | TInterfacedDispatchObject = class(TObject, IUnknown,
|
---|
| 55 | IInterfaceObjectReference, IDispatch)
|
---|
| 56 | protected
|
---|
| 57 | {IInterface}
|
---|
| 58 | FRefCount: Integer;
|
---|
| 59 | function QueryInterface(const IID: TGUID; out Obj): HResult;
|
---|
| 60 | {$IFDEF RESEARCH_MODE} virtual; {$ENDIF} stdcall;
|
---|
| 61 | function _AddRef: Integer; stdcall;
|
---|
| 62 | function _Release: Integer; stdcall;
|
---|
| 63 | {IInterfaceObjectReference}
|
---|
| 64 | function GetObject: TObject;
|
---|
| 65 | {IDispatch}
|
---|
| 66 | function GetTypeInfoCount(out Count: Integer): HResult; stdcall;
|
---|
| 67 | function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult; stdcall;
|
---|
| 68 | function GetIDsOfNames(const IID: TGUID; Names: Pointer;
|
---|
| 69 | NameCount, LocaleID: Integer; DispIDs: Pointer): HResult; virtual; stdcall;
|
---|
| 70 | function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
|
---|
| 71 | Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult;
|
---|
| 72 | virtual; stdcall;
|
---|
| 73 | public
|
---|
| 74 | procedure AfterConstruction; override;
|
---|
| 75 | class function NewInstance: TObject; override;
|
---|
| 76 | property RefCount: Integer read FRefCount;
|
---|
| 77 | end;
|
---|
| 78 |
|
---|
| 79 | implementation
|
---|
| 80 |
|
---|
| 81 | { TInterfacedDispatchObject }
|
---|
| 82 |
|
---|
| 83 | class function TInterfacedDispatchObject.NewInstance: TObject;
|
---|
| 84 | begin
|
---|
| 85 | Result := inherited NewInstance;
|
---|
| 86 | TInterfacedDispatchObject(Result).FRefCount := 1;
|
---|
| 87 | end;
|
---|
| 88 |
|
---|
| 89 | procedure TInterfacedDispatchObject.AfterConstruction;
|
---|
| 90 | begin
|
---|
| 91 | InterlockedDecrement(FRefCount);
|
---|
| 92 | end;
|
---|
| 93 |
|
---|
| 94 | function TInterfacedDispatchObject._AddRef: Integer;
|
---|
| 95 | begin
|
---|
| 96 | Result := InterlockedIncrement(FRefCount);
|
---|
| 97 | end;
|
---|
| 98 |
|
---|
| 99 | function TInterfacedDispatchObject._Release: Integer;
|
---|
| 100 | begin
|
---|
| 101 | Result := InterlockedDecrement(FRefCount);
|
---|
| 102 | if Result = 0 then
|
---|
| 103 | Destroy;
|
---|
| 104 | end;
|
---|
| 105 |
|
---|
| 106 | function TInterfacedDispatchObject.QueryInterface(const IID: TGUID;
|
---|
| 107 | out Obj): HResult;
|
---|
| 108 | begin
|
---|
| 109 | if GetInterface(IID, Obj) then
|
---|
| 110 | Result := 0
|
---|
| 111 | else
|
---|
| 112 | Result := E_NOINTERFACE;
|
---|
| 113 | end;
|
---|
| 114 |
|
---|
| 115 | function TInterfacedDispatchObject.GetIDsOfNames(const IID: TGUID;
|
---|
| 116 | Names: Pointer; NameCount, LocaleID: Integer; DispIDs: Pointer): HResult;
|
---|
| 117 | begin
|
---|
| 118 | Result := DISP_E_UNKNOWNNAME;
|
---|
| 119 | end;
|
---|
| 120 |
|
---|
| 121 | function TInterfacedDispatchObject.GetObject: TObject;
|
---|
| 122 | begin
|
---|
| 123 | Result := Self;
|
---|
| 124 | end;
|
---|
| 125 |
|
---|
| 126 | function TInterfacedDispatchObject.GetTypeInfo(Index, LocaleID: Integer;
|
---|
| 127 | out TypeInfo): HResult;
|
---|
| 128 | begin
|
---|
| 129 | Result := DISP_E_BADINDEX;
|
---|
| 130 | end;
|
---|
| 131 |
|
---|
| 132 | function TInterfacedDispatchObject.GetTypeInfoCount(
|
---|
| 133 | out Count: Integer): HResult;
|
---|
| 134 | begin
|
---|
| 135 | Count := 0;
|
---|
| 136 | Result := S_OK;
|
---|
| 137 | end;
|
---|
| 138 |
|
---|
| 139 | function TInterfacedDispatchObject.Invoke(DispID: Integer;
|
---|
| 140 | const IID: TGUID; LocaleID: Integer; Flags: Word; var Params; VarResult,
|
---|
| 141 | ExcepInfo, ArgErr: Pointer): HResult;
|
---|
| 142 | begin
|
---|
| 143 | Result := S_OK;
|
---|
| 144 | end;
|
---|
| 145 |
|
---|
| 146 | end.
|
---|