Solved

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

Posted on 2004-03-25
8
1,468 Views
Last Modified: 2012-06-21
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
Comment
Question by:MichealMcLoughlin
8 Comments
 
LVL 5

Expert Comment

by:g0rath
ID: 10677927
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
 
LVL 4

Expert Comment

by:xassets
ID: 10677984
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
 
LVL 5

Expert Comment

by:g0rath
ID: 10677999
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Expert Comment

by:WilfredoPerez
ID: 10678017
You can create new project and make 2 classes parent child and combine both projects into one
0
 
LVL 27

Expert Comment

by:Ark
ID: 10682504
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
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11424409
PAQed - no points refunded (of 100)

modulo
Community Support Moderator
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now