Send file name to already running app

BlitzPlus Forums/BlitzPlus Beginners Area/Send file name to already running app

DjBigWorm(Posted 2005) [#1]
Hi Fellow Blitzers,

I am writting an app that uses the command line to set certain flags and load files. When the app is already running and I double click on a file associated with my prog, I want to be able to detect that 1: my prog is already running and then send a message to my prog and have it load up the new file into the already running app. Instead of running two instances of the same program. Any steps or pointers to help me out will be greatly appriciated. Thanks in advance:)


semar(Posted 2005) [#2]
With the use of API you can detect if your program is already running.

If so, you can use the clipboard (again, API) to communicate between the program just launched, and the program already running. You may use a communication protocol, so to avoid problems during other clipboard tasks.

In pseudo code:

Const protocol$ = "#!#"
- program begins
- file_to_open$ = command_line
- if (the same program is already running) then
clipboard$ = protocol$ + file_to_open$
end
endif

.(program running normally)
while not ESC
if (clipboard is not empty) then
if mid$(clipboard,1,3) = protocol$ then
file_to_open$ = mid$(clipboard,4)
process file_to_open$
endif
endif
.
.
Wend
End



Hope this helps,
Sergio.


DjBigWorm(Posted 2005) [#3]
I was hoping for a working example. I understand the process just need syntax. Thanks for the help though:)