Interaction between programs

BlitzPlus Forums/BlitzPlus Programming/Interaction between programs

CASO(Posted 2006) [#1]
Is there a way to make one of my programs to interact with another without commandline$() because I want one to send info to the other while they are both running?

For Example: updating or adding features to an old program like plugins.

Commandline can only be submitted at the beginning of a program. Right?


Pineapple(Posted 2006) [#2]
You could possibly do it through TCP, using your local IP address, sorta client/server affair!

[edit]
Plugin wise, you could pump the bytes of different apps through TCP, update a sorta 'plugin' list, then when a user wants to use a plugin, call ExecFile, with the required app name!!!
[/edit]

Just a thought


CASO(Posted 2006) [#3]
I am not really in a situation that would accomidate anything with a "server"

As far as plugins Execfile wouldn't allow the kind of interaction i want


WolRon(Posted 2006) [#4]
I haven't tried it but I would assume the Windows API commands (like SendMessage or PostMessage) might help...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/messagesandmessagequeues/messagesandmessagequeuesreference/messagesandmessagequeuesfunctions/sendmessage.asp


CASO(Posted 2006) [#5]
Ok, but 2 problems

1.I don't really know how to use Windows API commands

2.What do I do about RECEIVING information


Grey Alien(Posted 2006) [#6]
ok, easy non-technical solution. Make one program write data commands into a text file. Have the other program check the file for changes every second or so and process accordingly. To avoid file locking problems you could make incremental file names.


Pineapple(Posted 2006) [#7]
Not being funny, but TCP is a perfect way for applications to talk to each other in Blitz... Grey Aliens solution means that your hard drive will be accessed every second, just think what that will do for the read/write speed of other applications!

About your problems:-

1) Windows API is a collection of 'open' functions within Windows that let programmers harness the power (if you will) of the OS... The key to harnessing this extra function ability (if you will), is by reading the read me file in your blitz+root/userlibs/ folder.. or, you could just do this:-

1) Create a file in your user lib folder called "WinAPI.DECLS"... e.g. "C:\Program Files\BlitzPlus\userlibs\WinAPI.DECLS"

Now, type this in the file and save:-

.lib "Advapi32.dll"
GetUserName%(strBuffer*,wSize*):"GetUserNameA"

This is a command within WinAPI that returns the name of the current user of windows... now don't be fooled, because unlike Blitz+ functions, the name is actually returned in the parameter, this function (in Blitz terms) returns an integer, corresponding to the amount of characters copied.

The best way to descibe this is by showing an example... If you wrote the DECLS file correctly, fire up Blitz+, and run this:-



WinAPI sits in your C:\Windows\System32\ folder (That where the .lib file 'Advapi32.dll' is.. if you wanna peek), The best thing to do is search in MSDN for WinAPI32, and also, read the read me file I mentioned earlier

Now, regarding PostMessage and SendMessage... I'm sure Blitz+ uses these functions, because these functions are used for messages between Windows, and an app... You would have to write your own DLL, with it's own callback function, and if you don't now C\C++, your knackered!

Now don't get me wrong, it may be possible to do what you want to do, but TCP is the easy... non hard drivin option... and if you don't understand TCP... here's an example of a real life app that uses it:-

CLIENT:


If TCP is not your answer, well, I've tried, but good luck on your project anyway!

Dabz

Note: I only mentioned ExecFile, because if it boils down to your application being two or more seperate applications, you could fire up each application using ExecFile, then use a TCP mechanism to communicate between them!


Grey Alien(Posted 2006) [#8]
I'd use TCP/IP too, just thought I'd post an easy non-tech solution, useful for testing too.

Dabz: Try using [codebox] instead of [code] !


kfprimm(Posted 2006) [#9]
simplier way to find the username...
Function CurrentUser$()
	Return GetEnv("username")
End Function



Pineapple(Posted 2006) [#10]
I didnt know that one KP... Sweet!!!

:)


Sonari Eclipsi Onimari(Posted 2006) [#11]
*chuckles... I had the same prob before... I did use the TCP method and it worked fine. Lol


Buggy(Posted 2006) [#12]
Just wondering... would you have to have internet access to do the TCP/IP thing?


WolRon(Posted 2006) [#13]
No, even though TCP/IP stands for Transfer Control Protocol/Internet Protocol, it can be used for LAN's just as well as WAN's.

Basically, it's a communication protocol, and isn't restricted to any specific area/range. It can be used however you like.


TomToad(Posted 2006) [#14]
You can use TCP/IP by making one program a "server" and the other the "client." The client will access the server program with the IP address 127.0.0.1 . Look at the example client/server programs in the help file under CreateTCPServer() command

Edit: Hmm, somehow I ended up in the BlitzPlus forum and I thought I was in the Blitz3D forum. How I got access here when I don't have blitzplus, I don't know :)
However, the same thing applies about the IP 127.0.0.1 . But the commands themselves might be different.