Jump to content

kihor

Members
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. That is wonderful! It really works! Thanks a lot.
  2. T tried your approach. Unfortunately, it didn't help. But thanks for your reply.
  3. Thanks for your reply. RIDL definition is following: [ uuid(F59E7744-DBC5-4544-A3DA-FF71C41A7DEE), version(1.0) ] library TestCOM { importlib("stdole2.tlb"); interface IMyCOM; coclass MyCOM; [ uuid(6C0484FA-26EE-4945-913A-78146C8449C2), helpstring("Interface for MyCOM Object"), oleautomation ] interface IMyCOM: IDispatch { [id(0x00000065)] BSTR _stdcall DoIt(void); }; [ uuid(B64A68CB-EBAC-42C7-B753-9BCBD87EC57E), helpstring("MyCOM") ] coclass MyCOM { [default] interface IMyCOM; }; };
  4. Hello, I am trying to implement COM object in Delphi. This is test COM object and its main module looks like this: unit MyCOM; {$WARN SYMBOL_PLATFORM OFF} interface uses Windows, ActiveX, Classes, ComObj, TestCOM_TLB, StdVcl; type TMyCOM = class(TAutoObject, IMyCOM) public function DoIt: WideString; stdcall; end; TMyComObjectFactory = class(TAutoObjectFactory) protected function GetProgID: string; override; end; const SValue: WideString = 'It works!'; implementation uses ComServ; function TMyCOM.DoIt: WideString; stdcall; begin Result := SValue; end; { TMyComObjectFactory } function TMyComObjectFactory.GetProgID: string; begin Result := 'DeNovo.MyCOM'; end; initialization TMyComObjectFactory.Create(ComServer, TMyCOM, Class_MyCOM, ciMultiInstance, tmApartment); end. I register this DLL with regsvr32 without problem. Then I try to invoke COM function via the following code in separate application: procedure TForm1.btnInvokeMyCOMClick(Sender: TObject); var MyCOM: Variant; begin MyCOM := CreateOleObject('DeNovo.MyCOM'); ShowMessage(MyCOM.DoIt); end; I contantly get the memorry access error. Meanwhile when I am trying to exchange integer data - everything works fine. Can you give me some clues how to cope with this WideString memory issue?
×