Solved

Communicate string between two instances of program

Posted on 2004-08-26
3
210 Views
Last Modified: 2010-05-02
I have created a program that opens a media file when the file is double clicked. The program tests if another instance of the program is already running and closes if App.PrevInstance=true.

My problem is that I would like to pass the contents of the Command$ function to the first instance of the program so the new file can be loaded.

What is the simplest way to transfew a string to another instance of the same application?
0
Comment
Question by:andrewstr
3 Comments
 
LVL 3

Accepted Solution

by:
nichia earned 300 total points
ID: 11908951
This is the simplest way:

"Use DDE to make an editor where a single instance handles all requests"
http://www.vb-helper.com/howto_one_instance_dde_editor.html

This is somewhat more difficult:

"Use SendMessage to make an editor where a single instance handles all requests"
http://www.vb-helper.com/howto_one_instance_sendmessage_editor.html

And this is unreasonably difficult:

"Registering File Associations and Passing Command Line Parameters to an Existing App Instance"
http://www.vbaccelerator.com/home/VB/Code/Libraries/Shell_Projects/Registering_File_Associations/article.asp
0
 
LVL 8

Expert Comment

by:plq
ID: 11910396
Ugh DDE is a nightmare.

Stick it in a file or save it in the registry. GetSettingEx and SaveSettingEx or let me know if you need a full registry class. Use scripting of VB Open to save a file/
0
 

Author Comment

by:andrewstr
ID: 11916614
Is used the DDE method, but it was a pain to get it working. It didn't help that the example cited above is not correct as is. I had to make some modifications to get it working enough to understand what was going on.

I may have used the file/registry method but I wasn't sure how to get the original app to check for a new setting without using a Timer.

Thanks for the tips!
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question