|
-
Jul 30th, 2001, 07:14 AM
#1
Thread Starter
Frenzied Member
Passing values between 2 programs
I have 2 VB exe files and I was wondering is it possible to shell to another exe and pass the contents of a variable.
e.g.
Program1.exe
text1.text = "Test"
Program2.exe
text1.text = program1(text1.text)
I know the example sux but it gives you an idea of what I am trying to do..
Mega.
"If at first you don't succeed, then skydiving is not for you"
-
Jul 30th, 2001, 08:05 AM
#2
Member
You'd have to do Winsock, DDE, or other interapplication communication stuff. Nobody knows how to use DDE, though .
If you want to communicate between two VB projects, just make a project group (VB5+).
-
Jul 30th, 2001, 08:09 AM
#3
or you could pass arguments to program2, like this:
Programs1's code:
VB Code:
Dim strBlah As String
strBlah = "hello"
Shell "c:\program2.exe " & strBlah
Programs2's code:
VB Code:
Public strBlah As String
Private Sub Form_Load()
strBlah = Command$
Text1.Text = strBlah
End Sub
-
Jul 30th, 2001, 08:14 AM
#4
Retired VBF Adm1nistrator
I've a few other ways of doing it.
1) Use the registry.
GetSetting and SaveSetting would suffice.
2) Use File I/O.
Save a file somewhere on the HDD, and the other app checks every so often if the file exists, and if it is, then deal with the information contained within appropriately.
3) Use mail slots.
I dunno much about this one.
4) Store a value directly in memory using APIs.
I would not take this approach.
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Jul 30th, 2001, 08:28 AM
#5
If you want to take plenderj's 4th piece of advice, I would suggest that you store it by using the GlobalAddAtom() and GlobalDeleteAtom() functions. If you really want to spice up your App, you would create a custom message, either by adding to WM_USER or by calling the RegisterWindowMessage() function. To recieve these messages, just subclass your window, and check in the callback for your message, e.g:
VB Code:
Case WM_MYMESSAGE:
' Message recieved
-
Jul 30th, 2001, 08:40 AM
#6
Fanatic Member
DDE is one way to go. You could also try making them both activeX exes, which might work. DDE is probably the easiest to do, all you have to do is set up a text box that is hidden set at linkmode=2 on both applications. The rest wouldn't be too difficult. You'd have to set up all your DDE capable controls (textbox and label as far as i know) to linkmode=1. When you use your applications in tandem, you'll use the dde methods of the textbox that's hidden to gather data from the other program.
-
Jul 30th, 2001, 10:27 AM
#7
Thread Starter
Frenzied Member
Thanks for that everybody. Lots of suggestions.
Initially all I need to pass is one value so Nullus's suggestion would do in this instance however it is worth investigatin the others.
Thanks again,
Mega.
"If at first you don't succeed, then skydiving is not for you"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|