Solved

OLE Application Server : Interfacing Excel XP RTD Functions

Posted on 2001-08-21
2
1,532 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How to run this video in webbrowse ? 2 67
APK file name 7 63
Deploying Delphi Application on Web Server 3 78
FMX enumerated colours 2 70
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now