Solved

Passing values from one exe to another exe

Posted on 2000-03-10
6
130 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA saving file message display 5 72
VB6 - Convert HH:MM into Decimal 8 62
Automatic Email Reminder 4 58
Export PDF Form fields to Access  or Excel  in Tab order 16 80
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

837 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