Solved

Passing values from one exe to another exe

Posted on 2000-03-10
6
127 Views
Last Modified: 2012-06-22
Hi experts! I need to pass ByVal few Thru/False variables from one executable to another, in order to start(or not) some processes. Could you, please, give me a hand?
0
Comment
Question by:GinaP
6 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 2605720
Use an ActiveX EXE with public variables in a standard module.
0
 
LVL 1

Expert Comment

by:Neal Hartman
ID: 2606192
I found the GetSettings and SaveSettings functions to be fast and reliable. You don't have to worry about another app's reliablity.
0
 
LVL 18

Expert Comment

by:mdougan
ID: 2606200
Emoreau has the most robust answer, but you can also use an older technology called DDE, if your requirements are simple enough.

To use the ActiveX EXE approach, create a new vb project, an when asked which template to use, choose ActiveX.EXE

This will create a project with a class module in it.  You should code this class to do the processes that you have mentioned, and perhaps you want to create two public functions or subs in the class:

Public Sub StartProcess()
'   here you call the code to start the process
End sub

Public Sub StopProcess()
'   here you call the code to stop the process
End sub


When done, compile your EXE.  This register's your class as an ActiveX Ole Server (local).  After you compile the first time, go to the Compile tab of the Project Properties box and select the option called "Binary Compatible", and in the textbox below the option, make sure to browse for the EXE that you just created.  This ensures that any program that you create in the future will not have "Registration" problems.

In a new standard VB EXE project, go to the Project | References menu, and you should see the name of your ActiveX EXE listed there.  Select it.  If you had called your class clsMyProcess and you compiled your ActiveX EXE to Cool.EXE then you should see Cool listed in this references menu.

In your code you will have a statement such as:

Dim x as New clsMyProcess

x.StartProcess

....


x.StopProcess

When you compile your second program and then build a setup program for it, it will tell you that it has found a local Ole Server that it depends upon.  You'll need to make sure that your ole server is included in the distribution.

You also have the option of making your ActiveX EXE a "remote ole server", meaning that you could have that EXE running on a server somewhere, and you can set up your second application to start and stop the process through this ActiveX EXE on the remote machine.  To do this, you'll have to use DCOM, which stands for distributed component object model, I think.  That gets a little more complex, but I'll throw that out for discussion.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 3

Accepted Solution

by:
paulstamp earned 100 total points
ID: 2607462
If you just want to pass them byval then simply use command line params when shelling your 2nd program.

ie if your second profram is myapp.exe :

  call Shell("c:\myapp.exe x=1 y=2")


In the second program (myapp.exe" these parameters appear in the system variable COMMAND$. Just parse that to retrieve the values, ie :

    x = val(mid$(command$, instr$(command$, "x=")+2,1))
    y = val(mid$(command$, instr$(command$, "y=")+2,1))
 

0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2607465
Sorry - just reread the question - obviously the above code could easily be modified to read 0 and -1 as true/false
0
 

Author Comment

by:GinaP
ID: 2608071
Thank you very much paulstamp's. Your answer is great: it is easy, very little code and it works perfectly for my purposes!
Thanks a lot to all of you guys, who gave me the answers. They are greatly appreciated.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

707 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

13 Experts available now in Live!

Get 1:1 Help Now