Solved

OLE Application Server : Interfacing Excel XP RTD Functions

Posted on 2001-08-21
2
1,546 Views
Last Modified: 2007-12-19
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


0
Comment
Question by:mgesiot
2 Comments
 
LVL 2

Accepted Solution

by:
hhamster earned 200 total points
ID: 6409191
At what point do you hang-up with TLBs?
Do you need a TLB for the above code?

Have you tried the Delphi's Type Lybrary Editor?
What version of Delphi are you using?
0
 

Author Comment

by:mgesiot
ID: 6409771
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
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question