Solved

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

Posted on 2004-03-25
8
1,506 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 28

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

726 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