• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1528
  • Last Modified:

With Parameters, How to shell calc.exe and bring it into focus when minimized?

Experts

I have an executable (child.exe) that needs to be launched from a visual basic (Parent.exe)

the child.exe can be called with Command Line Parameters

three different ways to launch the application

Using a previously answered question
( How to shell calc.exe and bring it into focus when minimized?)

i'm able to launch the application and activate it if its minimized

But how can I pass parameters to the Child.exe from the Parent.exe if the Executable is already running

All help is greatly appreciated




0
MichealMcLoughlin
Asked:
MichealMcLoughlin
1 Solution
 
g0rathCommented:
and you tried

Shell Path2Cal & "Calc.exe", vbNormalFocus

of course you could also use

ShellExecute

check out this example

http://vbnet.mvps.org/index.html?code/shell/shellexecute.htm
0
 
xassetsCommented:
I don't think you can pass a new command line to an existing process, but there are alternatives

1. Check App.PrevInstance and if it returns true, use FindWindow etc to get its hWnd and then use SendMessage or PostMessage to send a WM_CLOSE message to terminate the previous instance. Then your instance can carry on

2. Make the application an ActiveX EXE. Then your second instance can invoke a Class Method on the first instance and pass the command line paramters to it.

3. Implement a message handler, and use a WM_USER message to communicate from the second instance to the first instance. The message can carry a pointer to the command line provided its in global shared memory.

4. Same as 3. but use a file to pass the parameters instead of global shared memory.

0
 
g0rathCommented:
of course maybe you've allready done this and the program just isn't in focus

then you could use


Private Declare Function SetFocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long


Dim windowHwnd as Long

windowHwnd = FindWindow(vbNullString,"Calculator")
Call SetFocus(windowHwnd)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
WilfredoPerezCommented:
You can create new project and make 2 classes parent child and combine both projects into one
0
 
ArkCommented:
Sorry if I misunderstand your question, but probably you're looking for smth like this:
http://www.freevbcode.com/ShowCode.Asp?ID=2201
>>When you associate your application with data files, often you don't need to open a new a instance of application when a file is doubleclicked. Instead, you just want to send a command string (file name) to the previous instance. This application demonstrates a technique that allows you to do this without subclassing, using an invisible command button. The same technique can be useful for sending messages between two applications.<<
0
 
moduloCommented:
PAQed - no points refunded (of 100)

modulo
Community Support Moderator
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now