Jump to content

kihor

Members
  • Content Count

    5
  • Joined

  • Last visited

Posts posted by kihor


  1. 9 hours ago, DelphiUdIT said:

     

    If you want, you can try this.

     

    Is the same COM but with new application: you don't need to register the COM :classic_smile:

     

    Try to unregsiter the old one.

     

    After that build the projetc group (it is setting for WIn64 but you can change for WIn32) and run ... all is working without register the COM thanks to SxS technology (SideBySide).

    The EXE and DLL will be put in Bin32 and Bin64 (and there are already the manifests).

     

    There is a ReadMe and some Manifests (they are all equal excpet for the manifest that is included in the Project1 options).

     

    Bye

    Demo COM SxS.zip

     

    Thanks a lot! I will try this.


  2. 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;
      };
    
    };

     


  3. 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?

     

     

×