Solved

Passing values from one exe to another exe

Posted on 2000-03-10
6
128 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
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.

 
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

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

Suggested Solutions

Title # Comments Views Activity
Write data from SQL to CSV file - position 1 52
Visual Studio search word table and return Cell index 8 48
TT Auto Dashboard 13 82
Advice in Xamarin 21 52
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

912 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

22 Experts available now in Live!

Get 1:1 Help Now