Unit MSDASC_1_0_TLB;

//  Imported MSDASC on 01.12.2013 14:50:04 from C:\Program Files\Common Files\System\Ole DB\oledb32.dll

{$mode delphi}{$H+}

interface

// Dependency: stdole v2 (stdole2.pas)
//  Warning: renamed record member 'type' in tagSTATSTG to 'type_'
//  Warning: renamed method 'Reset' in IDBBinderProperties to 'Reset_'
Uses
  Windows,ActiveX,Classes,Variants,stdole2,ActiveXContainer;
Const
  MSDASCMajorVersion = 1;
  MSDASCMinorVersion = 0;
  MSDASCLCID = 0;
  LIBID_MSDASC : TGUID = '{2206CEB0-19C1-11D1-89E0-00C04FD7A829}';

  IID_IDataSourceLocator : TGUID = '{2206CCB2-19C1-11D1-89E0-00C04FD7A829}';
  CLASS_DataLinks : TGUID = '{2206CDB2-19C1-11D1-89E0-00C04FD7A829}';
  IID_IDBPromptInitialize : TGUID = '{2206CCB0-19C1-11D1-89E0-00C04FD7A829}';
  IID_IDataInitialize : TGUID = '{2206CCB1-19C1-11D1-89E0-00C04FD7A829}';
  CLASS_MSDAINITIALIZE : TGUID = '{2206CDB0-19C1-11D1-89E0-00C04FD7A829}';
  CLASS_PDPO : TGUID = '{CCB4EC60-B9DC-11D1-AC80-00A0C9034873}';
  IID_IPersistFile : TGUID = '{0000010B-0000-0000-C000-000000000046}';
  IID_IPersist : TGUID = '{0000010C-0000-0000-C000-000000000046}';
  CLASS_RootBinder : TGUID = '{FF151822-B0BF-11D1-A80D-000000000000}';
  IID_IBindResource : TGUID = '{0C733AB1-2A1C-11CE-ADE5-00AA0044773D}';
  IID_IAuthenticate : TGUID = '{79EAC9D0-BAF9-11CE-8C82-00AA004BA90B}';
  IID_ICreateRow : TGUID = '{0C733AB2-2A1C-11CE-ADE5-00AA0044773D}';
  IID_IRegisterProvider : TGUID = '{0C733AB9-2A1C-11CE-ADE5-00AA0044773D}';
  IID_IDBBinderProperties : TGUID = '{0C733AB3-2A1C-11CE-ADE5-00AA0044773D}';
  IID_IDBProperties : TGUID = '{0C733A8A-2A1C-11CE-ADE5-00AA0044773D}';
  IID_IErrorInfo : TGUID = '{1CF2B120-547D-101B-8E65-08002B2BD119}';
  IID_IMarshal : TGUID = '{00000003-0000-0000-C000-000000000046}';
  IID_IStream : TGUID = '{0000000C-0000-0000-C000-000000000046}';
  IID_ISequentialStream : TGUID = '{0C733A30-2A1C-11CE-ADE5-00AA0044773D}';

//Enums

//Forward declarations

Type
 IDataSourceLocator = interface;
 IDataSourceLocatorDisp = dispinterface;
 IDBPromptInitialize = interface;
 IDataInitialize = interface;
 IPersistFile = interface;
 IPersist = interface;
 IBindResource = interface;
 IAuthenticate = interface;
 ICreateRow = interface;
 IRegisterProvider = interface;
 IDBBinderProperties = interface;
 IDBProperties = interface;
 IErrorInfo = interface;
 IMarshal = interface;
 IStream = interface;
 ISequentialStream = interface;

//Map CoClass to its default interface

 DataLinks = IDataSourceLocator;
 MSDAINITIALIZE = IDataInitialize;
 PDPO = IPersistFile;
 RootBinder = IBindResource;

//records, unions, aliases

 P_RemotableHandle = ^_RemotableHandle;

 wireHWND = P_RemotableHandle;
 P__MIDL_IWinTypes_0009 = ^__MIDL_IWinTypes_0009;

 __MIDL_IWinTypes_0009 =  record
    case Integer of
     0: (hInproc : Integer);
     1: (hRemote : Integer);
 end;
 _RemotableHandle = packed record
     fContext : Integer;
     u : __MIDL_IWinTypes_0009;
 end;
 P_COSERVERINFO = ^_COSERVERINFO;

 P_COAUTHINFO = ^_COAUTHINFO;

 _COSERVERINFO = packed record
     dwReserved1 : LongWord;
     pwszName : PWideChar;
     pAuthInfo : P_COAUTHINFO;
     dwReserved2 : LongWord;
 end;
 P_COAUTHIDENTITY = ^_COAUTHIDENTITY;

 _COAUTHINFO = packed record
     dwAuthnSvc : LongWord;
     dwAuthzSvc : LongWord;
     pwszServerPrincName : PWideChar;
     dwAuthnLevel : LongWord;
     dwImpersonationLevel : LongWord;
     pAuthIdentityData : P_COAUTHIDENTITY;
     dwCapabilities : LongWord;
 end;
 _COAUTHIDENTITY = packed record
     User : PWord;
     UserLength : LongWord;
     Domain : PWord;
     DomainLength : LongWord;
     Password : PWord;
     PasswordLength : LongWord;
     Flags : LongWord;
 end;
 PtagDBPROPIDSET = ^tagDBPROPIDSET;

 tagDBPROPIDSET = packed record
     rgPropertyIDs : PLongWord;
     cPropertyIDs : LongWord;
     guidPropertySet : TGUID;
 end;
 PtagDBPROPSET = ^tagDBPROPSET;

 PtagDBPROP = ^tagDBPROP;

 tagDBPROPSET = packed record
     rgProperties : PtagDBPROP;
     cProperties : LongWord;
     guidPropertySet : TGUID;
 end;
 PtagDBID = ^tagDBID;

 P__MIDL_DBStructureDefinitions_0001 = ^__MIDL_DBStructureDefinitions_0001;

 __MIDL_DBStructureDefinitions_0001 =  record
    case Integer of
     0: (guid : TGUID);
     1: (pguid : PGUID);
 end;
 P__MIDL_DBStructureDefinitions_0002 = ^__MIDL_DBStructureDefinitions_0002;

 __MIDL_DBStructureDefinitions_0002 =  record
    case Integer of
     0: (pwszName : PWideChar);
     1: (ulPropid : LongWord);
 end;
 tagDBID = packed record
     uGuid : __MIDL_DBStructureDefinitions_0001;
     eKind : LongWord;
     uName : __MIDL_DBStructureDefinitions_0002;
 end;
 tagDBPROP = packed record
     dwPropertyID : LongWord;
     dwOptions : LongWord;
     dwStatus : LongWord;
     colid : tagDBID;
     vValue : OleVariant;
 end;
 PtagDBPROPINFOSET = ^tagDBPROPINFOSET;

 PtagDBPROPINFO = ^tagDBPROPINFO;

 tagDBPROPINFOSET = packed record
     rgPropertyInfos : PtagDBPROPINFO;
     cPropertyInfos : LongWord;
     guidPropertySet : TGUID;
 end;
 tagDBPROPINFO = packed record
     pwszDescription : PWideChar;
     dwPropertyID : LongWord;
     dwFlags : LongWord;
     vtType : Word;
     vValues : OleVariant;
 end;
 P_LARGE_INTEGER = ^_LARGE_INTEGER;

 _LARGE_INTEGER = packed record
     QuadPart : Int64;
 end;
 P_ULARGE_INTEGER = ^_ULARGE_INTEGER;

 _ULARGE_INTEGER = packed record
     QuadPart : QWord;
 end;
 PtagSTATSTG = ^tagSTATSTG;

 P_FILETIME = ^_FILETIME;

 _FILETIME = packed record
     dwLowDateTime : LongWord;
     dwHighDateTime : LongWord;
 end;
 tagSTATSTG = packed record
     pwcsName : PWideChar;
     type_ : LongWord;
     cbSize : _ULARGE_INTEGER;
     mtime : _FILETIME;
     ctime : _FILETIME;
     atime : _FILETIME;
     grfMode : LongWord;
     grfLocksSupported : LongWord;
     clsid : TGUID;
     grfStateBits : LongWord;
     reserved : LongWord;
 end;

//interface declarations

// IDataSourceLocator : Microsoft OLE DB Service Component Automation Interface

 IDataSourceLocator = interface(IDispatch)
   ['{2206CCB2-19C1-11D1-89E0-00C04FD7A829}']
   function Get_hWnd : Integer; safecall;
   procedure Set_hWnd(const phwndParent:Integer); safecall;
    // PromptNew : PromptNew 
   function PromptNew:IDispatch;safecall;
    // PromptEdit : PromptEdit 
   function PromptEdit(var ppADOConnection:IDispatch):WordBool;safecall;
    // hWnd : Returns and sets the parent window. 
   property hWnd:Integer read Get_hWnd write Set_hWnd;
  end;


// IDataSourceLocator : Microsoft OLE DB Service Component Automation Interface

 IDataSourceLocatorDisp = dispinterface
   ['{2206CCB2-19C1-11D1-89E0-00C04FD7A829}']
    // PromptNew : PromptNew 
   function PromptNew:IDispatch;dispid 1610743810;
    // PromptEdit : PromptEdit 
   function PromptEdit(var ppADOConnection:IDispatch):WordBool;dispid 1610743811;
    // hWnd : Returns and sets the parent window. 
   property hWnd:Integer dispid 1610743808;
  end;


// IDBPromptInitialize : IDBPromptInitialize Interface

 IDBPromptInitialize = interface(IUnknown)
   ['{2206CCB0-19C1-11D1-89E0-00C04FD7A829}']
    // PromptDataSource : Method PromptDataSource 
   function PromptDataSource(pUnkOuter:IUnknown;hWndParent:wireHWND;dwPromptOptions:LongWord;cSourceTypeFilter:LongWord;var rgSourceTypeFilter:LongWord;pwszszzProviderFilter:PWideChar;var riid:GUID;var ppDataSource:IUnknown):HRESULT;stdcall;
    // PromptFileName : Method PromptFileName 
   function PromptFileName(hWndParent:wireHWND;dwPromptOptions:LongWord;pwszInitialDirectory:PWideChar;pwszInitialFile:PWideChar;out ppwszSelectedFile:PWideChar):HRESULT;stdcall;
  end;


// IDataInitialize : IDataInitialize Interface

 IDataInitialize = interface(IUnknown)
   ['{2206CCB1-19C1-11D1-89E0-00C04FD7A829}']
    // GetDataSource : Method GetDataSource 
   function GetDataSource(pUnkOuter:IUnknown;dwClsCtx:LongWord;pwszInitializationString:PWideChar;var riid:GUID;var ppDataSource:IUnknown):HRESULT;stdcall;
    // GetInitializationString : Method GetInitializationString 
   function GetInitializationString(pDataSource:IUnknown;fIncludePassword:ShortInt;out ppwszInitString:PWideChar):HRESULT;stdcall;
    // CreateDBInstance : Method CreateDBInstance 
   function CreateDBInstance(var clsidProvider:GUID;pUnkOuter:IUnknown;dwClsCtx:LongWord;pwszReserved:PWideChar;var riid:GUID;out ppDataSource:IUnknown):HRESULT;stdcall;
    // RemoteCreateDBInstanceEx :  
   function RemoteCreateDBInstanceEx(var clsidProvider:GUID;pUnkOuter:IUnknown;dwClsCtx:LongWord;pwszReserved:PWideChar;var pServerInfo:_COSERVERINFO;cmq:LongWord;var rgpIID:PGUID;out rgpItf:IUnknown;out rghr:HResult):HRESULT;stdcall;
    // LoadStringFromStorage : Method LoadStringFromStorage 
   function LoadStringFromStorage(pwszFileName:PWideChar;out ppwszInitializationString:PWideChar):HRESULT;stdcall;
    // WriteStringToStorage : Method WriteStringToStorage 
   function WriteStringToStorage(pwszFileName:PWideChar;pwszInitializationString:PWideChar;dwCreationDisposition:LongWord):HRESULT;stdcall;
  end;


// IPersist : 

 IPersist = interface(IUnknown)
   ['{0000010C-0000-0000-C000-000000000046}']
    // GetClassID :  
   function GetClassID(out pClassID:GUID):HRESULT;stdcall;
  end;


// IPersistFile : 

 IPersistFile = interface(IPersist)
   ['{0000010B-0000-0000-C000-000000000046}']
    // IsDirty :  
   procedure IsDirty;safecall;
    // Load :  
   procedure Load(pszFileName:PWideChar;dwMode:LongWord);safecall;
    // Save :  
   procedure Save(pszFileName:PWideChar;fRemember:Integer);safecall;
    // SaveCompleted :  
   procedure SaveCompleted(pszFileName:PWideChar);safecall;
    // GetCurFile :  
   procedure GetCurFile(out ppszFileName:PWideChar);safecall;
  end;


// IBindResource : 

 IBindResource = interface(IUnknown)
   ['{0C733AB1-2A1C-11CE-ADE5-00AA0044773D}']
    // RemoteBind :  
   function RemoteBind(pUnkOuter:IUnknown;pwszURL:PWideChar;dwBindURLFlags:LongWord;var rguid:GUID;var riid:GUID;pAuthenticate:IAuthenticate;pSessionUnkOuter:IUnknown;var piid:GUID;var ppSession:IUnknown;var pdwBindStatus:LongWord;out ppUnk:IUnknown):HRESULT;stdcall;
  end;


// IAuthenticate : 

 IAuthenticate = interface(IUnknown)
   ['{79EAC9D0-BAF9-11CE-8C82-00AA004BA90B}']
    // Authenticate :  
   function Authenticate(out phwnd:wireHWND;out pszUsername:PWideChar;out pszPassword:PWideChar):HRESULT;stdcall;
  end;


// ICreateRow : 

 ICreateRow = interface(IUnknown)
   ['{0C733AB2-2A1C-11CE-ADE5-00AA0044773D}']
    // RemoteCreateRow :  
   function RemoteCreateRow(pUnkOuter:IUnknown;pwszURL:PWideChar;dwBindURLFlags:LongWord;var rguid:GUID;var riid:GUID;pAuthenticate:IAuthenticate;pSessionUnkOuter:IUnknown;var piid:GUID;var ppSession:IUnknown;var pdwBindStatus:LongWord;var ppwszNewURL:PWideChar;out ppUnk:IUnknown):HRESULT;stdcall;
  end;


// IRegisterProvider : 

 IRegisterProvider = interface(IUnknown)
   ['{0C733AB9-2A1C-11CE-ADE5-00AA0044773D}']
    // RemoteGetURLMapping :  
   function RemoteGetURLMapping(pwszURL:PWideChar;dwReserved:QWord;out pclsidProvider:GUID):HRESULT;stdcall;
    // SetURLMapping :  
   function SetURLMapping(pwszURL:PWideChar;dwReserved:QWord;var rclsidProvider:GUID):HRESULT;stdcall;
    // UnregisterProvider :  
   function UnregisterProvider(pwszURL:PWideChar;dwReserved:QWord;var rclsidProvider:GUID):HRESULT;stdcall;
  end;


// IDBProperties : 

 IDBProperties = interface(IUnknown)
   ['{0C733A8A-2A1C-11CE-ADE5-00AA0044773D}']
    // RemoteGetProperties :  
   function RemoteGetProperties(cPropertyIDSets:LongWord;var rgPropertyIDSets:tagDBPROPIDSET;var pcPropertySets:LongWord;out prgPropertySets:PtagDBPROPSET;out ppErrorInfoRem:IErrorInfo):HRESULT;stdcall;
    // RemoteGetPropertyInfo :  
   function RemoteGetPropertyInfo(cPropertyIDSets:LongWord;var rgPropertyIDSets:tagDBPROPIDSET;var pcPropertyInfoSets:LongWord;out prgPropertyInfoSets:PtagDBPROPINFOSET;var pcOffsets:LongWord;out prgDescOffsets:PQWord;var pcbDescBuffer:LongWord;var ppDescBuffer:PWord;out ppErrorInfoRem:IErrorInfo):HRESULT;stdcall;
    // RemoteSetProperties :  
   function RemoteSetProperties(cPropertySets:LongWord;var rgPropertySets:tagDBPROPSET;cTotalProps:LongWord;out rgPropStatus:LongWord;out ppErrorInfoRem:IErrorInfo):HRESULT;stdcall;
  end;


// IDBBinderProperties : 

 IDBBinderProperties = interface(IDBProperties)
   ['{0C733AB3-2A1C-11CE-ADE5-00AA0044773D}']
    // Reset_ :  
   procedure Reset_;safecall;
  end;


// IErrorInfo : 

 IErrorInfo = interface(IUnknown)
   ['{1CF2B120-547D-101B-8E65-08002B2BD119}']
    // GetGUID :  
   function GetGUID(out pguid:GUID):HRESULT;stdcall;
    // GetSource :  
   function GetSource(out pBstrSource:WideString):HRESULT;stdcall;
    // GetDescription :  
   function GetDescription(out pBstrDescription:WideString):HRESULT;stdcall;
    // GetHelpFile :  
   function GetHelpFile(out pBstrHelpFile:WideString):HRESULT;stdcall;
    // GetHelpContext :  
   function GetHelpContext(out pdwHelpContext:LongWord):HRESULT;stdcall;
  end;


// IMarshal : 

 IMarshal = interface(IUnknown)
   ['{00000003-0000-0000-C000-000000000046}']
    // GetUnmarshalClass :  
   function GetUnmarshalClass(var riid:GUID;var pv:pointer;dwDestContext:LongWord;var pvDestContext:pointer;mshlflags:LongWord;out pCid:GUID):HRESULT;stdcall;
    // GetMarshalSizeMax :  
   function GetMarshalSizeMax(var riid:GUID;var pv:pointer;dwDestContext:LongWord;var pvDestContext:pointer;mshlflags:LongWord;out pSize:LongWord):HRESULT;stdcall;
    // MarshalInterface :  
   function MarshalInterface(pstm:IStream;var riid:GUID;var pv:pointer;dwDestContext:LongWord;var pvDestContext:pointer;mshlflags:LongWord):HRESULT;stdcall;
    // UnmarshalInterface :  
   function UnmarshalInterface(pstm:IStream;var riid:GUID;out ppv:Ppointer):HRESULT;stdcall;
    // ReleaseMarshalData :  
   function ReleaseMarshalData(pstm:IStream):HRESULT;stdcall;
    // DisconnectObject :  
   function DisconnectObject(dwReserved:LongWord):HRESULT;stdcall;
  end;


// ISequentialStream : 

 ISequentialStream = interface(IUnknown)
   ['{0C733A30-2A1C-11CE-ADE5-00AA0044773D}']
    // RemoteRead :  
   function RemoteRead(out pv:Byte;cb:LongWord;out pcbRead:LongWord):HRESULT;stdcall;
    // RemoteWrite :  
   function RemoteWrite(var pv:Byte;cb:LongWord;out pcbWritten:LongWord):HRESULT;stdcall;
  end;


// IStream : 

 IStream = interface(ISequentialStream)
   ['{0000000C-0000-0000-C000-000000000046}']
    // RemoteSeek :  
   procedure RemoteSeek(dlibMove:_LARGE_INTEGER;dwOrigin:LongWord;out plibNewPosition:_ULARGE_INTEGER);safecall;
    // SetSize :  
   procedure SetSize(libNewSize:_ULARGE_INTEGER);safecall;
    // RemoteCopyTo :  
   procedure RemoteCopyTo(pstm:IStream;cb:_ULARGE_INTEGER;out pcbRead:_ULARGE_INTEGER;out pcbWritten:_ULARGE_INTEGER);safecall;
    // Commit :  
   procedure Commit(grfCommitFlags:LongWord);safecall;
    // Revert :  
   procedure Revert;safecall;
    // LockRegion :  
   procedure LockRegion(libOffset:_ULARGE_INTEGER;cb:_ULARGE_INTEGER;dwLockType:LongWord);safecall;
    // UnlockRegion :  
   procedure UnlockRegion(libOffset:_ULARGE_INTEGER;cb:_ULARGE_INTEGER;dwLockType:LongWord);safecall;
    // Stat :  
   procedure Stat(out pstatstg:tagSTATSTG;grfStatFlag:LongWord);safecall;
    // Clone :  
   procedure Clone(out ppstm:IStream);safecall;
  end;

//CoClasses
  CoDataLinks = Class
  Public
    Class Function Create: IDataSourceLocator;
    Class Function CreateRemote(const MachineName: string): IDataSourceLocator;
  end;

  TAxcDataLinks = Class(TActiveXContainer)
  Private
    FServer:IDataSourceLocator;
  Public
    constructor Create(TheOwner: TComponent); override;
    destructor Destroy; override;
    property OleServer:IDataSourceLocator read FServer;
  Published
    property Align;
    property Anchors;
    property AutoSize;
    property BorderSpacing;
    property ChildSizing;
    property ClientHeight;
    property ClientWidth;
    property Constraints;
    property DockSite;
    property DragCursor;
    property DragKind;
    property DragMode;
    property Enabled;
    property ParentShowHint;
    property PopupMenu;
    property ShowHint;
    property TabOrder;
    property TabStop;
    property UseDockManager default True;
    property Visible;
    property OnContextPopup;
    property OnDockDrop;
    property OnDockOver;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDock;
    property OnEndDrag;
    property OnEnter;
    property OnExit;
    property OnGetSiteInfo;
    property OnGetDockCaption;
    property OnResize;
    property OnStartDock;
    property OnStartDrag;
    property OnStatusText;
    property OnUnDock;
    property Active;
  end;

  CoMSDAINITIALIZE = Class
  Public
    Class Function Create: IDataInitialize;
    Class Function CreateRemote(const MachineName: string): IDataInitialize;
  end;

  CoPDPO = Class
  Public
    Class Function Create: IPersistFile;
    Class Function CreateRemote(const MachineName: string): IPersistFile;
  end;

  CoRootBinder = Class
  Public
    Class Function Create: IBindResource;
    Class Function CreateRemote(const MachineName: string): IBindResource;
  end;

implementation

uses comobj;

Class Function CoDataLinks.Create: IDataSourceLocator;
begin
  Result := CreateComObject(CLASS_DataLinks) as IDataSourceLocator;
end;

Class Function CoDataLinks.CreateRemote(const MachineName: string): IDataSourceLocator;
begin
  Result := CreateRemoteComObject(MachineName,CLASS_DataLinks) as IDataSourceLocator;
end;

constructor TAxcDataLinks.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
  FServer:=CoDataLinks.Create;
  ComServer:=FServer;
end;

destructor TAxcDataLinks.Destroy;
begin
  inherited destroy;
end;

Class Function CoMSDAINITIALIZE.Create: IDataInitialize;
begin
  Result := CreateComObject(CLASS_MSDAINITIALIZE) as IDataInitialize;
end;

Class Function CoMSDAINITIALIZE.CreateRemote(const MachineName: string): IDataInitialize;
begin
  Result := CreateRemoteComObject(MachineName,CLASS_MSDAINITIALIZE) as IDataInitialize;
end;

Class Function CoPDPO.Create: IPersistFile;
begin
  Result := CreateComObject(CLASS_PDPO) as IPersistFile;
end;

Class Function CoPDPO.CreateRemote(const MachineName: string): IPersistFile;
begin
  Result := CreateRemoteComObject(MachineName,CLASS_PDPO) as IPersistFile;
end;

Class Function CoRootBinder.Create: IBindResource;
begin
  Result := CreateComObject(CLASS_RootBinder) as IBindResource;
end;

Class Function CoRootBinder.CreateRemote(const MachineName: string): IBindResource;
begin
  Result := CreateRemoteComObject(MachineName,CLASS_RootBinder) as IBindResource;
end;

end.
