Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Calling an COM object from Delphi (https://www.delphipraxis.net/141278-calling-com-object-delphi.html)

Razor 6. Okt 2009 08:33


Calling an COM object from Delphi
 
Hey!


Is there a article about this that shows how you create a com object from imported type library in delphi?An example would be great.

Sherlock 6. Okt 2009 08:43

Re: Calling an COM object from Delphi
 
Here you are:

http://delphi.about.com/od/comoleact...ledge_base.htm

Sherlock

Razor 6. Okt 2009 17:00

Re: Calling an COM object from Delphi
 
Ok so is this proper COM i really couldn't find an existing delphi example so i decided to port some c++ code but i guess it didnt go well.I am really tired from all this 5 hours for 1 example i am trying to compile :wall: :wall:

Delphi-Quellcode:
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleServer, WINSATLib_TLB, StdCtrls,comobj, ComCtrls,activex, ExtCtrls ;

  Type TMyCallback = class (TComObject,IWInSatInitiateEvents)
   function WinSATComplete(hresult: HResult; strDescription: PWideChar): HResult; stdcall;
   function WinSATUpdate(uCurrentTick: longword; uTickTotal: longword; strCurrentState: PWideChar): HResult; stdcall;
   constructor Create;

   end;

var
Form2: TForm2;
i:IWinSATInitiateEvents;
k:_RemotableHandle;
progresposition:integer;
icurrent,itotal:longword;
t:tmycallback;
sa:string;

function TMyCallback.WinSATComplete(hresult: HResult; strDescription: PWideChar): HResult; stdcall;
begin
if Succeeded(hresult) then result:=strtoint(strDescription)
else showmessage(strDescription);
end;

function TMyCallback.WinSATUpdate(uCurrentTick: longword; uTickTotal: longword; strCurrentState: PWideChar): HResult; stdcall;
var
Assesment:^IInitiateWinSATAssessment;
hr:HRESULT;
begin
if uticktotal>0 then begin
  progresposition:=100*ucurrentTick div utickTotal;
  result:=s_ok;
  Assesment:=nil;
  CoInitializeEx(nil, COINIT_APARTMENTTHREADED);
  OleCheck(CoCreateInstance(
      Class_CInitiateWinSAT,
      nil,
      CLSCTX_INPROC_SERVER,
      IInitiateWinSATAssessment,
     Assesment));
  if FAILED(hr) then
   showmessage('Failed to create an instance of IInitiateWinSATAssessment. Failed with ');
end;
end;

mkinzler 6. Okt 2009 17:04

Re: Calling an COM object from Delphi
 
We told you, to wait for the end of the 24Hour span! And we also announced to close threads you open regarding the same problem.
It seems that you're not willing to understand/recognize our warnings!

* * * CLOSED * * *


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:51 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz