0

How can I create a RTD Client on Delphi? I have no idea how to start, I need to get values almost like an Excel spreadsheet, something like

=RTD("gartle.rtd",,"YahooFinanceWatchList","AAPL","Open")
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
GPGomes
  • 147
  • 3
  • 14
  • Which part of this are you struggling with? I wonder if you know anything about COM? If not then you need to learn to walk before you run. – David Heffernan Nov 06 '14 at 14:34
  • One thing I wonder about is that you used twice the term client. Do you mean server? – David Heffernan Nov 06 '14 at 14:39
  • I don't know much about COM, I'm studying right now... And I mean really client, I'm trying to get data from a application the same way Excel does (as the fuction that I posted) – GPGomes Nov 06 '14 at 15:51
  • Excel is the client. In your example, `gartle.rtd` is the server. Do you really mean client? – David Heffernan Nov 06 '14 at 16:06
  • Yes, I really mean client, I need to acess gartle.rtd (for example), I need to replace Excel by my application – GPGomes Nov 06 '14 at 16:14
  • 1
    That's not so hard then. You need to create an instance of the COM automation object and call its methods. These are all documented. However, you have probably hit upon the wrong solution to your problem. It would be much easier to use a webservice interface to extract real time stock market information. Really no need for you to pretend to be Excel here. – David Heffernan Nov 06 '14 at 17:41
  • Thanks, I'll study COM automation and try to solve the problem. I would prefer to use anything web related but isn't exactly my call. – GPGomes Nov 06 '14 at 19:08
  • I feel sorry for you. The job is trivial to do going directly to a web service. Just because your boss is hooked on Excel, it seems that he can see no other way to tackle the problem! – David Heffernan Nov 07 '14 at 07:28

2 Answers2

1

It says here: http://support.microsoft.com/kb/285339 that to provide an RTL server to Excel you need to implement the IRtdServer interface, by this logic, you should be able to instantiate an existing implementation using default COM methods yourself. (YMMV)

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Stijn Sanders
  • 35,982
  • 11
  • 45
  • 67
  • Do you have any example of how to do that? – GPGomes Nov 06 '14 at 13:59
  • @David: exactly, but how does Excel get from `"gartle.rtd"` to a live interface pointer to an object that implements IRtdServer? If Excel does it (via _plain_ COM calls), so can we, but I don't think I have RTD providers here to check. @GPGomes, could you open regedit and search `HKEY_CLASSES_ROOT` for `gartle.rtd`? – Stijn Sanders Nov 07 '14 at 15:22
  • I didn't read your answer clearly enough. It seems that you already knew this. Sorry. Anyway, presumably it is possible to create one of these COM objects. But that would be a very obscure way to get real time financials! – David Heffernan Nov 07 '14 at 16:27
1

As Stijn mentioned, you need to create a COM automation object which implements IRtdServer. The Delphi declarations for this is below:

// *********************************************************************//
// Interface: IRTDUpdateEvent
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {A43788C1-D91B-11D3-8F39-00C04F3651B8}
// *********************************************************************//
IRTDUpdateEvent = interface(IDispatch)
  ['{A43788C1-D91B-11D3-8F39-00C04F3651B8}']
  procedure UpdateNotify; safecall;
  function Get_HeartbeatInterval: Integer; safecall;
  procedure Set_HeartbeatInterval(plRetVal: Integer); safecall;
  procedure Disconnect; safecall;
  property HeartbeatInterval: Integer read Get_HeartbeatInterval write Set_HeartbeatInterval;
end;

// *********************************************************************//
// Interface: IRtdServer
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {EC0E6191-DB51-11D3-8F3E-00C04F3651B8}
// *********************************************************************//
IRtdServer = interface(IDispatch)
  ['{EC0E6191-DB51-11D3-8F3E-00C04F3651B8}']
  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;
Paul Klink
  • 66
  • 2