7 Replies - 1005 Views - Last Post: 05 October 2013 - 09:54 PM Rate Topic: -----

#1 Roland_J  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 18-August 13

Passing variables between exe's

Posted 27 September 2013 - 02:41 PM

Hi all

What is the simplest way to pass values/variables between different .exe programs.(VB6) Seems like a fundamental thing(to me) is a ball-ache in VB. The obvious way would be to poke some memory location in one program, and peek in another, but VB seems to use pipes. Surely it must be easier than that.

The mouse's cursor position, for example, are variables that can be read by any program in windows. Arent there a bunch of 'user' registers available that can be used as a scratchpad?

Regards
Roland

Is This A Good Question/Topic? 0
  • +

Replies To: Passing variables between exe's

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8377
  • View blog
  • Posts: 31,138
  • Joined: 12-June 08

Re: Passing variables between exe's

Posted 27 September 2013 - 02:54 PM

Why would you figure it would be fundamental thing to do? That seems like a very haphazard thing to wish for.. for security, consistent input, etc. Where's the functional code supposed to listen to? Is it to halt everything except listen for what ever event to be thrown up? How would it know what app to return to?

Off the top of my head - you have have files checked, databases checked, or even (go a slightly longer route) and use UDP.
Was This Post Helpful? 0
  • +
  • -

#3 Roland_J  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 18-August 13

Re: Passing variables between exe's

Posted 27 September 2013 - 09:54 PM

I would think it's fundamental as in the program needs to respond to it's environment, without too much code overhead. An example is reading the caps lock value. Just one line;
if My.Computer.Keyboard.CapsLock Then......



I have some I/O on USB/serial. Because events are happening at odd intervals, I don't want each app to try open and close the port to read what's happening because some will miss the event. (I am new to all of this)
So I figure that if one simple app reads/writes to the ports and updates a scratchpad, then the values can easily be read by other apps.

Maybe there are a bunch of MS system variables that are really not used? I only need a about 15 values to be passed around.
Was This Post Helpful? 0
  • +
  • -

#4 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,755
  • Joined: 26-March 09

Re: Passing variables between exe's

Posted 27 September 2013 - 11:53 PM

Can you give a little more background and a specific example of what you're trying to achieve?

Are all the exe's your programs (i.e. did you write them and have full control over them)?? If so, you could maybe make one of them a standard exe and the others activex exe's, that way you can read/write property variables between them as well as raising events.
Was This Post Helpful? 1
  • +
  • -

#5 Roland_J  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 18-August 13

Re: Passing variables between exe's

Posted 28 September 2013 - 08:34 AM

I'm using Roborealm on a custom machine that I've made. I have three uP boards controlling motors and solenoids, and reading a hex keypad. I wanted to use a VB6 program to handle the top level admin, like presenting pictures to the operator and allowing the user to make choices. Labels will appear on the screen, next to buttons (ATM style), and the user will press a button. This is read by the Pic board and sent to the VB program as a character. This value determines a number of other variables that must then be passed to Roborealm for it to do the correct filtering. Another Pic board reads the position of the camera on a robot and needs to let Roborealm know which filters to apply. But it also controls motors that the VB program must be aware of, so I can't give control of the port to Roborealm exclusively. The VB front end decides if errors are happening, and must only pass variables to Roborealm.

I am considering however, that maybe I should do everything within Roborealm and run VB scripts from within, but I wanted to have separate programs, including the robot, handshaking through variables so as to prevent a mishap.
Was This Post Helpful? 0
  • +
  • -

#6 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,755
  • Joined: 26-March 09

Re: Passing variables between exe's

Posted 28 September 2013 - 09:26 AM

I know we briefly touched on RoboRealm in a previous post of yours, so I'm assuming you got the link between VB6 and it working (it had an API interface if I remember rightly?).

Anyway, one way that I might approach this would be to have a VB6 EXE (Your admin program) and a VB6 ActiveX EXE (your Comms program) which would be your link between your PIC boards and the admin program.

You would run the Admin program that would create an instance of the ActiveX EXE.

The ActiveX EXE could have it's own properties and methods and would also be able to raise events to the Admin program. So, your admin program would do all the "visual" things and handle the link to RoboRealm, and the ActiveX EXE does the low level comms between the PIC's and the admin program.

So, things like motor positions could be held in properties in the ActiveX EXE and read by the admin program on a timer or on demand, depending on what you want to do.

I know this is a very top level suggestion, but if it sounds like it's what you're trying to achieve then it might be worth you investigating it further.
Was This Post Helpful? 0
  • +
  • -

#7 Roland_J  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 18-August 13

Re: Passing variables between exe's

Posted 05 October 2013 - 10:02 AM

In the interests of getting the job done, what I'm doing is using a simple as possible program to do the version selection, as in a choice of 1/24. The VB program will then minimise or close, on calling a choice1.robo ... choice24.robo program.

The Roborealm program will then make all the visual decisions and step with the robot as well as print a label at the end.

While my pic programs use a lot of conditional flags, I'm still unsure if this is how one structures VB programs. In a pic, one sets up the configuration, say A, then set up the environment, B, and run a program loop C that does the work.

But VB ? runs A B C A B C A B C... so I am correct in assuming that the program will be something like (in quasi code)
If A = 0 then
config gets set up here......
A = 1
B = 0
C = 0
endif

if A = 1 and B = 0 then
environ gets set up here......
B= 1
endif

if A= 1 and B =1 and C = 0 then
C = 1
endif

if C = 1 then
prog goes here..............
endif

? Help appreciated.
Was This Post Helpful? 0
  • +
  • -

#8 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 571
  • View blog
  • Posts: 2,979
  • Joined: 19-May 09

Re: Passing variables between exe's

Posted 05 October 2013 - 09:54 PM

I haven't fully digested what you have said, but I have the feeing that you're thinking about this in terms of any application having access to any other applications memory simply by hitting that memory address. Windows restricts this on an opsys level, the idea being to minimize the problems that bugs can cause. Here's a link to a Windows overview of interprocess communication: http://msdn.microsof...4(v=vs.85).aspx . You can also look at marshaling, proxies and stubs, shared memory and the like. But you can't just poke another exe's memory addresses directly unless someone has come up with a trick of some sort.

As maj has said, the easiest way (when you know how) to accomplish what you are looking for is to create an ActiveX EXE. That becomes an object that you can reference in your program. Create a property in your ActiveX ExE, expose a method that runs your RoboRealm program. Think of the EXE as a wrapper that brokers interprocess requests for communication with your RoboRealm program.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1