PC Review


Reply
Thread Tools Rate Thread

Strange Shell process...!

 
 
ALESSANDRO Baraldi
Guest
Posts: n/a
 
      23rd May 2004
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




--
@Alex (Alessandro Baraldi)
---------------------------------------------------------------------------
http://www.sitocomune.com/
http://www.mantuanet.it/alessandro.baraldi/
---------------------------------------------------------------------------


 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      24th May 2004
"ALESSANDRO Baraldi" <(E-Mail Removed)> wrote in message
news:c8ojqa$j2h$(E-Mail Removed)
> 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

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

(please reply to the newsgroup)


 
Reply With Quote
 
ALESSANDRO Baraldi
Guest
Posts: n/a
 
      24th May 2004

"Dirk Goldgar" <(E-Mail Removed)> ha scritto nel messaggio
news:%23m%(E-Mail Removed)...
[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.



 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      25th May 2004
"ALESSANDRO Baraldi" <(E-Mail Removed)> wrote in message
news:c8t7u6$9js$(E-Mail Removed)
> "Dirk Goldgar" <(E-Mail Removed)> ha scritto nel messaggio
> news:%23m%(E-Mail Removed)...
> [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.

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

(please reply to the newsgroup)


 
Reply With Quote
 
ALESSANDRO Baraldi
Guest
Posts: n/a
 
      25th May 2004

"Dirk Goldgar" <(E-Mail Removed)> ha scritto nel messaggio
news:%(E-Mail Removed)...
[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.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell and Process.Start do not work =?Utf-8?B?UGhpbG9zb3BoYWll?= Microsoft Excel Programming 3 14th Jul 2007 10:20 PM
Problem using Process.start to shell bill@abc.com Microsoft ASP .NET 6 27th Jul 2006 07:33 PM
Shell process user with .Net and Vb6 =?Utf-8?B?U2ViaXR0aQ==?= Microsoft ASP .NET 0 28th Jan 2005 12:03 PM
Launch Shell process under different identity =?Utf-8?B?VHJpcHM=?= Microsoft Dot NET Framework Forms 3 6th Apr 2004 05:27 PM
Launch shell process under different identity =?Utf-8?B?VHJpcHM=?= Microsoft Dot NET 0 6th Apr 2004 01:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:58 PM.