| View previous topic :: View next topic |
| Author |
Message |
Elec0 Expert Cheater
Reputation: 0
Joined: 21 Nov 2007 Posts: 188 Location: Out of my mind, back in five minutes.
|
Posted: Thu Jan 17, 2008 8:07 am Post subject: [VB6]Question About Using Shell |
|
|
I was wondering if it were possible to open a program and set a variable in that program from another program, like this:
| Code: |
Call Shell("c:\Project1.exe Var=111")
|
Would something like that be possible?
~Elec0
_________________
|
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Thu Jan 17, 2008 8:21 am Post subject: Re: [VB6]Question About Using Shell |
|
|
| Elec0 wrote: | I was wondering if it were possible to open a program and set a variable in that program from another program, like this:
| Code: |
Call Shell("c:\Project1.exe Var=111")
|
Would something like that be possible?
~Elec0 |
Sorry. you cant pass variables with shell.
| Code: | | Shell "C:\temp\blastrox.exe", vbNormalFocus |
shell(pathname.exe, [windowstyle as vbappwinstyle=vbnormalfocus]) As Double[/code]
_________________
Intel over amd yes.
Last edited by NINTENDO on Thu Jan 17, 2008 8:24 am; edited 1 time in total |
|
| Back to top |
|
 |
Elec0 Expert Cheater
Reputation: 0
Joined: 21 Nov 2007 Posts: 188 Location: Out of my mind, back in five minutes.
|
Posted: Thu Jan 17, 2008 8:23 am Post subject: |
|
|
Is there anyway you can?
_________________
|
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Thu Jan 17, 2008 8:24 am Post subject: |
|
|
I dont know if there is
_________________
Intel over amd yes. |
|
| Back to top |
|
 |
Elec0 Expert Cheater
Reputation: 0
Joined: 21 Nov 2007 Posts: 188 Location: Out of my mind, back in five minutes.
|
Posted: Thu Jan 17, 2008 8:27 am Post subject: |
|
|
Dang, that would be nice. Hmm, I can think of one way, but it's crude and you have to have cooperation from the other program. I think I'll google it.
Thanks though, if you remember anything, please let me know.
~Elec0
Edit: Using
| Code: |
Call Shell("Blah.exe", vbnormalfocus)
|
Works just as well instead of using just the Shell "blah.exe", vbnormalfocus
_________________
|
|
| Back to top |
|
 |
stealthy17 Expert Cheater
Reputation: 0
Joined: 10 Apr 2007 Posts: 144 Location: The Netherlands
|
Posted: Thu Jan 17, 2008 8:52 am Post subject: |
|
|
| Use ShellExecute WinAPI it will allow params etc.
|
|
| Back to top |
|
 |
Elec0 Expert Cheater
Reputation: 0
Joined: 21 Nov 2007 Posts: 188 Location: Out of my mind, back in five minutes.
|
Posted: Thu Jan 17, 2008 8:55 am Post subject: |
|
|
Could you post how to use it please?
_________________
|
|
| Back to top |
|
 |
stealthy17 Expert Cheater
Reputation: 0
Joined: 10 Apr 2007 Posts: 144 Location: The Netherlands
|
Posted: Thu Jan 17, 2008 8:58 am Post subject: |
|
|
| Code: | Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hWnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Sub somebutton_Click()
Dim handle As Long
handle = ShellExecute(0, "Open", "c:\file.exe", "parameter", 0, SW_SHOWNORM)
End Sub |
|
|
| Back to top |
|
 |
Elec0 Expert Cheater
Reputation: 0
Joined: 21 Nov 2007 Posts: 188 Location: Out of my mind, back in five minutes.
|
Posted: Thu Jan 17, 2008 9:02 am Post subject: |
|
|
Cool, thanks.
Am I using it right?
| Code: |
Dim handle As Long
handle = ShellExecute(0, "Open", "c:\Project1.exe", "Var", 111, SW_SHOWNORM)
|
_________________
|
|
| Back to top |
|
 |
stealthy17 Expert Cheater
Reputation: 0
Joined: 10 Apr 2007 Posts: 144 Location: The Netherlands
|
Posted: Thu Jan 17, 2008 9:07 am Post subject: |
|
|
No like that it sends "Var" as arg[0] and 111 is set as directory (the start path)...
You could do it like this:
| Code: |
Dim handle As Long
handle = ShellExecute(0, "Open", "c:\Project1.exe", "Var=111", 0, SW_SHOWNORM)
|
The "Var=" is not even needed depending how Project1.exe handle it...
|
|
| Back to top |
|
 |
Elec0 Expert Cheater
Reputation: 0
Joined: 21 Nov 2007 Posts: 188 Location: Out of my mind, back in five minutes.
|
Posted: Thu Jan 17, 2008 9:11 am Post subject: |
|
|
The Var is declared a public variable at the start of the program.
Thanks, I'll try it.
Edit: The label didn't change when I loaded it up. (I have on load it sets a label to what the Var is.)
_________________
|
|
| Back to top |
|
 |
stealthy17 Expert Cheater
Reputation: 0
Joined: 10 Apr 2007 Posts: 144 Location: The Netherlands
|
Posted: Thu Jan 17, 2008 9:18 am Post subject: |
|
|
Use this:
| Code: | Dim handle As Long
handle = ShellExecute(0, "Open", "c:\Project1.exe", "111", 0, SW_SHOWNORM) |
Put this in Form_Load() of Project1.exe
| Code: | Dim strParam As String
strParam = Command()
Me.Caption = strParam |
|
|
| Back to top |
|
 |
Elec0 Expert Cheater
Reputation: 0
Joined: 21 Nov 2007 Posts: 188 Location: Out of my mind, back in five minutes.
|
Posted: Thu Jan 17, 2008 9:22 am Post subject: |
|
|
Thanks, I'll try once again.
Edit: Yay! It worked! Thanks. +Rep for you.
_________________
|
|
| Back to top |
|
 |
|