Strange Shell process...!

A

ALESSANDRO Baraldi

I from IT.

I use this Function to Shell the Applications i need, but the strange thing
is that if also I open the App
passing VbAppWinStyle this does not maintain the Focus, and don't use my
Parameter.
I need to Click on Task_Bar to PutFocus on it.
I use this Method because i can Shell any Application, and i need to return
PID process to convert on Hwnd.

Any one know why or have some other solution to try....?

Thanks.
Alessandro(IT)

W2K + A_XP

'My Module Function
Public Function OpenApp(strApp As String, Optional eWindowStyle As
VBA.VbAppWinStyle = vbNormalFocus) As Long
On Error GoTo OpenDoc_Err
Dim retval
Dim CmdLn As String
Dim Pid As Long
Dim hwndWindow As Long
Dim retExec As String
Dim tmpAPP As String
Dim ApplicationPaht As String
DoCmd.Hourglass True
ApplicationPaht = GetPathPart(strApp)
tmpAPP = strApp
If retExtension(tmpAPP) = "Exe" Then
CmdLn = tmpAPP
Else
retExec = fFindEXE(tmpAPP, ApplicationPaht)
If Not IsNothing(retExec) Then
CmdLn = retExec & " " & Chr(34) & tmpAPP & Chr(34)
Else
MsgBox "Nessun Eseguibile associato all'allegato...!", vbCritical,
"Avviso"
hwndWindow = 0
GoTo Exit_Here
End If
End If
Pid = Shell(CmdLn, eWindowStyle)
hwndWindow = InstanceToWnd(Pid)
Exit_Here:
OpenApp = hwndWindow
DoCmd.Hourglass False
Exit Function
OpenDoc_Err:
Resume Exit_Here
End Function
 
D

Dirk Goldgar

ALESSANDRO Baraldi said:
I from IT.

I use this Function to Shell the Applications i need, but the strange
thing is that if also I open the App
passing VbAppWinStyle this does not maintain the Focus, and don't use
my Parameter.
I need to Click on Task_Bar to PutFocus on it.
I use this Method because i can Shell any Application, and i need to
return PID process to convert on Hwnd.

Any one know why or have some other solution to try....?

Thanks.
Alessandro(IT)

W2K + A_XP

'My Module Function
Public Function OpenApp(strApp As String, Optional eWindowStyle As
VBA.VbAppWinStyle = vbNormalFocus) As Long
On Error GoTo OpenDoc_Err
Dim retval
Dim CmdLn As String
Dim Pid As Long
Dim hwndWindow As Long
Dim retExec As String
Dim tmpAPP As String
Dim ApplicationPaht As String
DoCmd.Hourglass True
ApplicationPaht = GetPathPart(strApp)
tmpAPP = strApp
If retExtension(tmpAPP) = "Exe" Then
CmdLn = tmpAPP
Else
retExec = fFindEXE(tmpAPP, ApplicationPaht)
If Not IsNothing(retExec) Then
CmdLn = retExec & " " & Chr(34) & tmpAPP & Chr(34)
Else
MsgBox "Nessun Eseguibile associato all'allegato...!",
vbCritical, "Avviso"
hwndWindow = 0
GoTo Exit_Here
End If
End If
Pid = Shell(CmdLn, eWindowStyle)
hwndWindow = InstanceToWnd(Pid)
Exit_Here:
OpenApp = hwndWindow
DoCmd.Hourglass False
Exit Function
OpenDoc_Err:
Resume Exit_Here
End Function

Alessandro, I'm, not sure I understand what you're saying, but have you
tried calling the ShellExecute API directly, using code similar to that
found at

http://www.mvps.org/access/api/api0018.htm

?
 
A

ALESSANDRO Baraldi

"Dirk Goldgar" <[email protected]> ha scritto nel messaggio
[CUT]
Alessandro, I'm, not sure I understand what you're saying, but have you
tried calling the ShellExecute API directly, using code similar to that
found at

http://www.mvps.org/access/api/api0018.htm

?
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Hi Dirk thanks for replay.

My Work is:
1)Execute many processes(applications or other any)
2)Check if any of this still alive, and if they are Killed
send INFO and Register TimeStart and TimeStop.

I use Shell to have PID parameter of my Processes, ShellExecute
don't return a valid Value(or i don't know how to use it to have Hwnd)
When i Shell an application i register PID and Hwnd of this, and on
Timer EVENT i cicle all my Hwnd(on a collection) and with [API]
IsWindows(hwnd)
i check if any Processes are killed.
This is the info about.(All Work good, the only problem was the WindowStyle.
I don't know why, but i need to use [API] SetWindowPos (mHwnd.........ecc..)
and the Application coming up on TOPView.

If you have a better solution or any suggestion to also understand this
problem.
I have thought to have made an/many errors...!

Bye.
Alessandro.
 
D

Dirk Goldgar

ALESSANDRO Baraldi said:
"Dirk Goldgar" <[email protected]> ha scritto nel messaggio
[CUT]
Alessandro, I'm, not sure I understand what you're saying, but have
you tried calling the ShellExecute API directly, using code similar
to that found at

http://www.mvps.org/access/api/api0018.htm

?

Hi Dirk thanks for replay.

My Work is:
1)Execute many processes(applications or other any)
2)Check if any of this still alive, and if they are Killed
send INFO and Register TimeStart and TimeStop.

I use Shell to have PID parameter of my Processes, ShellExecute
don't return a valid Value(or i don't know how to use it to have Hwnd)
When i Shell an application i register PID and Hwnd of this, and on
Timer EVENT i cicle all my Hwnd(on a collection) and with [API]
IsWindows(hwnd)
i check if any Processes are killed.
This is the info about.(All Work good, the only problem was the
WindowStyle. I don't know why, but i need to use [API] SetWindowPos
(mHwnd.........ecc..) and the Application coming up on TOPView.

If you have a better solution or any suggestion to also understand
this problem.
I have thought to have made an/many errors...!

I don't think I have anything better to suggest. My API guide says this
about the ShellExecute API: "If the function succeeds, the return value
is the instance handle of the application that was run, or the handle of
a dynamic data exchange (DDE) server application." I don't actually
know much about programming the Windows API -- I just follow the
cookbooks -- but I thought perhaps you could use this return value for
whatever you were doing.
 
A

ALESSANDRO Baraldi

"Dirk Goldgar" <[email protected]> ha scritto nel messaggio
[CUT]
I don't think I have anything better to suggest. My API guide says this
about the ShellExecute API: "If the function succeeds, the return value
is the instance handle of the application that was run, or the handle of
a dynamic data exchange (DDE) server application." I don't actually
know much about programming the Windows API -- I just follow the
cookbooks -- but I thought perhaps you could use this return value for
whatever you were doing.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Hi.
Also my giude says what you know, but making test
the ret parameter has not equal.
In a hold Post i find something about the difference beetwen Shell and
ShellExecute ret parameter, but probably for my english, i don't understand
good.

Thank again for 3d.

Bye.
Alessandro.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top