Link to home
Start Free TrialLog in
Avatar of mgesiot
mgesiot

asked on

OLE Application Server : Interfacing Excel XP RTD Functions

Hi
To know what I'm talking about goto:

http://msdn.microsoft.com/library/en-us/dnexcl2k2/html/odc_xlrtdbuild.asp
http://msdn.microsoft.com/library/en-us/dnexcl2k2/html/odc_xlrtdfaq.asp

I'm wondering where to start from.....
I've developped what I needed but when it comes to write the Type Library
I'm lost !!!!
The program gets compiled correctly, I register it correctly but then I can't use it because the Type Library is missing.
The most complicated problem is converting Types, since the IRtdServer Interface uses some types that seem to be non COM compatible, witch is NOT possible since this interface was built to be used only via COM.
The VB 6 example by Microsoft works correctly, but I need to use Delphi.

Here's some sample code:
-------------------------------
unit RtdTestAutoObj;

interface

uses
  ComObj, ActiveX, pG2RtdTest2_TLB, StdVcl, Excel_TLB, uCommonData;

Const SUCCESS = 1;

type
  TG2RtdTest2 = class(TAutoObject, IRtdServer, IG2RtdTest2)
  protected
    { Protected declarations }
    function  ServerStart(const CallbackObject: IRTDUpdateEvent): Integer;
safecall;
    function  ConnectData(TopicID: Integer; var Strings: PSafeArray; var
GetNewValues: WordBool): OleVariant; safecall;
    function  RefreshData(var TopicCount: Integer): PSafeArray; safecall;
    procedure DisconnectData(TopicID: Integer); safecall;
    function  Heartbeat: Integer; safecall;
    procedure ServerTerminate; safecall;
  end;

implementation

uses ComServ;

{ TG2RtdTest2 }

function TG2RtdTest2.ConnectData(TopicID: Integer; var Strings: PSafeArray;
var GetNewValues: WordBool): OleVariant;
Var
 i : Integer;
    pov : POleVariant;
    pc  : PChar;
begin
 i := High(RtData) + 1;
    SetLength(RtData, i+1);
    RtData[i].TCount := TopicID;

    pc := PChar(Strings.pvData);
    RtData[i].Titolo := String(pc);

    RtData[i].valore := '';
    RtData[i].NewData := False;
    Result := 'Connection OK';
end;

procedure TG2RtdTest2.DisconnectData(TopicID: Integer);
Var
 i : Integer;
begin
 For i := 0 to high(Rtdata) Do Begin
     If RtData[i].TCount = TopicID Then Begin
   RtData[i].TCount := 0;
            RtData[i].Titolo := '';
        end;
    End;
end;

function TG2RtdTest2.Heartbeat: Integer;
begin
 Result := SUCCESS;
end;

function TG2RtdTest2.RefreshData(var TopicCount: Integer): PSafeArray;
Var
 P : Pointer;
    Pov : Variant;
    i,x  : Integer;
begin
 x := 0 ;
 For i := 0 to High(RtData) Do Begin
     IF RtData[i].NewData Then Inc(x);
    End;

    If x > 0 Then Begin
     x := 0;
  Pov := VarArrayCreate([2,x], varVariant);
  For i := 0 to High(RtData) Do Begin
      IF RtData[i].TCount = TopicCount Then Begin
          Pov[0,x] := Variant(RtData[i].TCount);
             Pov[1,x] := Variant(RtData[i].valore);
                Inc(x);
         end;
     End;
        P := VarArrayLock(Pov);
        TopicCount := x;
        Result := PSafeArray(P);
        VarArrayUnlock(Pov);
    End Else
     TopicCount := 0;
end;

function TG2RtdTest2.ServerStart(const CallbackObject: IRTDUpdateEvent):
Integer;
begin
 CbObj := CallbackObject;
    result := SUCCESS;
end;

procedure TG2RtdTest2.ServerTerminate;
begin

end;

initialization
  TAutoObjectFactory.Create(ComServer, TG2RtdTest2, Class_G2RtdTest2,
    ciSingleInstance, tmApartment);
end.
-------------------------------

Please Help

please reply to my Email adress as well

By
Marco


ASKER CERTIFIED SOLUTION
Avatar of hhamster
hhamster
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mgesiot
mgesiot

ASKER

1) I haven't started the TLB since I don't know how to
convert the required types

2) I Do think so (look at Microsoft links for details)

3) YES, I used it but the problems are still the Types

4) Delphi 5.0 Ent (with all the upgrades)

Thanks for the interest