[.net] External program API

Started by
11 comments, last by Arild Fines 17 years, 10 months ago
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
my-eulogy - A blog about coding and gfxsdgi - Semi-Daily Game IdeaChunkyHacker - Viewer for Relic chunky formats (used in DOW)
Advertisement
Maybe the word '.NET assembly' is what you are looking for?
[s]--------------------------------------------------------[/s]chromecode.com - software with source code
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.
my-eulogy - A blog about coding and gfxsdgi - Semi-Daily Game IdeaChunkyHacker - Viewer for Relic chunky formats (used in DOW)
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.
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();}
my-eulogy - A blog about coding and gfxsdgi - Semi-Daily Game IdeaChunkyHacker - Viewer for Relic chunky formats (used in DOW)
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
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?
my-eulogy - A blog about coding and gfxsdgi - Semi-Daily Game IdeaChunkyHacker - Viewer for Relic chunky formats (used in DOW)
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).
Rob Loach [Website] [Projects] [Contact]
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();
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
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?
my-eulogy - A blog about coding and gfxsdgi - Semi-Daily Game IdeaChunkyHacker - Viewer for Relic chunky formats (used in DOW)

This topic is closed to new replies.

Advertisement