comobj.pp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2002 by Florian Klaempfl
  4. member of the Free Pascal development team.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$mode objfpc}
  12. {$H+}
  13. unit comobj;
  14. interface
  15. function CreateClassID : ansistring;
  16. function CreateComObject(const ClassID: TGUID) : IUnknown;
  17. function CreateRemoteComObject(const MachineName : WideString;const ClassID : TGUID) : IUnknown;
  18. function CreateOleObject(const ClassName : string) : IDispatch;
  19. function GetActiveOleObject(const ClassName: string) : IDispatch;
  20. implementation
  21. uses
  22. windows,activex;
  23. {$define FPC_COMOBJ_HAS_CREATE_CLASS_ID}
  24. function CreateClassID : ansistring;
  25. var
  26. ClassID : TCLSID;
  27. p : PWideChar;
  28. begin
  29. CoCreateGuid(ClassID);
  30. StringFromCLSID(ClassID,p);
  31. result:=p;
  32. CoTaskMemFree(p);
  33. end;
  34. function CreateComObject(const ClassID : TGUID) : IUnknown;
  35. begin
  36. {!!!!!!!}
  37. runerror(211);
  38. end;
  39. function CreateRemoteComObject(const MachineName : WideString;const ClassID : TGUID) : IUnknown;
  40. begin
  41. {!!!!!!!}
  42. runerror(211);
  43. end;
  44. function CreateOleObject(const ClassName : string) : IDispatch;
  45. begin
  46. {!!!!!!!}
  47. runerror(211);
  48. end;
  49. function GetActiveOleObject(const ClassName : string) : IDispatch;
  50. begin
  51. {!!!!!!!}
  52. runerror(211);
  53. end;
  54. end.