Solved

OLE Application Server : Interfacing Excel XP RTD Functions

Posted on 2001-08-21
2
1,554 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

707 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