Solved

Communicate string between two instances of program

Posted on 2004-08-26
3
209 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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now