1 Replies - 3243 Views - Last Post: 04 July 2012 - 06:41 AM Rate Topic: -----

#1 krunal1984   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-July 12

how to get access to a rtd application running on the system using C#

Posted 04 July 2012 - 05:22 AM

Hi Folks

i have a RTD application running developed by third party on my system. i want to access it using C# windows application.

the problem i am facing is i have a progid of the RTD application which i get when i drag drop the RTD field in Excel.

now i want to connect to the running application to get data and show the data in the gridview contol of C#.

i tried this code to get access

public class Class1
        public int CurrentValue { get; set; }

   // [Guid("EBD9B4A9-3E17-45F0-A1C9-E134043923D3")]

    public class RtdServer : IRtdServer
        private readonly Dictionary<int, Class1> _topics = new Dictionary<int, Class1>();
        private Timer _timer;

        public int ServerStart(IRTDUpdateEvent rtdUpdateEvent)
            _timer = new Timer(delegate { rtdUpdateEvent.UpdateNotify(); }, null, TimeSpan.Zero, TimeSpan.FromSeconds(5));
            return 1;

        public object ConnectData(int topicId, ref Array strings, ref bool getNewValues)
            var start = Convert.ToInt32(strings.GetValue(0).ToString());
            getNewValues = true;

            _topics[topicId] = new Class1 { CurrentValue = start };

            return start;

        public Array RefreshData(ref int topicCount)
            var data = new object[2, _topics.Count];
            var index = 0;

            foreach (var entry in _topics)
                data[0, index] = entry.Key;
                data[1, index] = entry.Value.CurrentValue;

            topicCount = _topics.Count;

            return data;

        public void DisconnectData(int topicId)

        public int Heartbeat() { return 1; }

        public void ServerTerminate() { _timer.Dispose(); }

        public static void RegisterFunction(Type t)
            Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(@"CLSID\{" + t.GUID.ToString().ToUpper() + @"}\Programmable");
            var key = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(@"CLSID\{" + t.GUID.ToString().ToUpper() + @"}\InprocServer32", true);
            if (key != null)
                key.SetValue("", System.Environment.SystemDirectory + @"\mscoree.dll", Microsoft.Win32.RegistryValueKind.String);

        public static void UnregisterFunction(Type t)
            Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey(@"CLSID\{" + t.GUID.ToString().ToUpper() + @"}\Programmable");

but it says either value cannot be null..

is their any other way to do that or am i doing something wrong in the code..

solution will be warmly appreciated..

thanks in advance


Is This A Good Question/Topic? 0
  • +

Replies To: how to get access to a rtd application running on the system using C#

#2 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6537
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: how to get access to a rtd application running on the system using C#

Posted 04 July 2012 - 06:41 AM

You might consider putting links or explanations to acronyms in posts.
RTD ??? Return To Deathstar? Rotating Tropical Depression? Red Tailed Deer? Really Terrible Design?


but it says either value cannot be null..

You provided over 70 lines of code. WHERE does it stop to tell you this?

What does this error mean?

Q: I do x and y happens which I didn't expect but I don't know how to figure out why. How do I debug and find my problem?

This post has been edited by tlhIn`toq: 04 July 2012 - 06:41 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1