Jump to content
  • Advertisement
Sign in to follow this  
e-u-l-o-g-y

[.net] External program API

This topic is 4566 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! Does anybody know of any good tutorials on programming an API for a .NET application? I would like to make it possible to access a program object, and thereby have direct control of the program. Any suggestions? -Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
Oh... sorry... I was a bit tired when I wrote the message.. what I meant was an external API to control the program like for instance photoshop has. I would like to have a couple of functions that gives you access to the application object from other programs.

Share this post


Link to post
Share on other sites
Just expose the application object (whatever you mean by that) as a public property of something (something static maybe?). Then any application that can use your assembly can access it. I don't quite know what you mean by 'have direct control of the program', but a standard .Net library is usable from other programs with nothing special.

Share this post


Link to post
Share on other sites
Hmm... ok... I'll try to explain a bit better: I have two different projects. One that contains a gui application, and one command line tool that makes it possible to manipulate the first program while it's running. I want the command line tool as well as any other program that includes an API assembly to be able to communicate with the instances of the gui program.

I expect the usage to look a bit like this:

foreach (GuiApplication app in GuiApplication.RunningInstances)
{
app.PerformSomeAction();
}

Share this post


Link to post
Share on other sites
may be a better way but you could always just write a little server in the main app. Then write a little API that communicates with the main app's server via sockets. The little API would have hooks for sending appropriately formatted data streams to the main app's server which would then execute them within the main app. Likewise you could have method calls which would query for info from the main app such as getting a list of objects and such.

-me

Share this post


Link to post
Share on other sites
Palidine: That might be a solution, but It's a bit hack-ish. I was hoping there's a way to retrieve managed objects from a running program, but there's perhaps no simple way?

Share this post


Link to post
Share on other sites
I wrote a little article on Plugin Interfaces in .NET a little while ago that covers how to implement a plugin archatecture into a .NET environment. In this case, your GUI application would be a plugin to the main console application. When you write a command into the console, you could call a function in the GUI Application (IPlugin).

Share this post


Link to post
Share on other sites
Have your GUI application expose an interface via remoting. Then your application can be accessed like this:


IApplication app = (IApplication)Activator.GetObject(typeof(IApplication), "tcp://localhost:1234/Application");
app.DoStuff();


Share this post


Link to post
Share on other sites
Rob Loach:
I've done something similar, but the problem with this approach is that the gui part of the program is dependent on the console part, which is undesirable in my situation, since I consider the console part to be an external tool.

Arild Fines:
Now that seems interesting.. Could you elaborate on how it works?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!