?
Solved

Passing values from one exe to another exe

Posted on 2000-03-10
6
Medium Priority
?
141 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 70

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Accepted Solution

by:
paulstamp earned 400 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

809 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