Solved

Passing values from one exe to another exe

Posted on 2000-03-10
6
129 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Paint/Redraw window while dragging 16 76
MsgBox 2 54
message box in access 4 46
TT Auto Dashboard 13 92
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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

786 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