-
Content Count
5 -
Joined
-
Last visited
Posts posted by kihor
-
-
41 minutes ago, DelphiUdIT said:If you want this is the global project (DLL_COM + APP) with WIDESTRING result use .... It's only a basic skeleton of course.
Bye
That is wonderful! It really works! Thanks a lot.
-
40 minutes ago, Ondrej Kelle said:Just an idea. Shouldn't the calling convention for an automation object be safecall rather than stdcall?
T tried your approach. Unfortunately, it didn't help. But thanks for your reply.
-
33 minutes ago, DelphiUdIT said:How is your RIDL definition of COM class ... may be there is the issue ...
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; }; };
-
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?
Memory access problem when exchanging WideString in OLE object written in Delphi
in Windows API
Posted
Thanks a lot! I will try this.