From: Shell on
OK, I've tried everything I can think of to make this work. Even some
suggestions from Google searches that specify that to make it work I
have to pass the user type (SHELLEXECUTEINFO) ByVal instead of
ByRef...which of course will not work.

The Code snippets follow:

<In the Main.bas>

Public Const SEE_MASK_CLASSKEY As Long = &H3
Public Const SEE_MASK_CLASSNAME As Long = &H1
Public Const SEE_MASK_CONNECTNETDRV As Long = &H80
Public Const SEE_MASK_DOENVSUBST As Long = &H200
Public Const SEE_MASK_FLAG_DDEWAIT As Long = &H100
Public Const SEE_MASK_FLAG_NO_UI As Long = &H400
Public Const SEE_MASK_HOTKEY As Long = &H20
Public Const SEE_MASK_ICON As Long = &H10
Public Const SEE_MASK_IDLIST As Long = &H4
Public Const SEE_MASK_INVOKEIDLIST As Long = &HC
Public Const SEE_MASK_NOCLOSEPROCESS As Long = &H40

Public Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
hWnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
lpIDList As Long
lpClass As String
hkeyClass As Long
dwHotKey As Long
hIcon As Long
hProcess As Long
End Type

Public SEI As SHELLEXECUTEINFO

Public Declare Function ShellExecuteEx Lib "shell32.dll" ( _
SEI As SHELLEXECUTEINFO) As Long

<In the Form's code>

Private Sub Open_Click()
Dim dRtn As Long, srcFile As String, SEI As SHELLEXECUTEINFO

dRtn = 0
With SEI
'Set the structure's size
.cbSize = Len(SEI)
'Seet the mask
.fMask = SEE_MASK_NOCLOSEPROCESS Or _
SEE_MASK_INVOKEIDLIST Or SEE_MASK_FLAG_NO_UI
'Set the owner window
.hWnd = Me.hWnd
'Show the properties
.lpVerb = "Open"
'Set the filename
.lpFile = Me.RTB.FileName
.lpParameters = vbNullChar
.lpDirectory = vbNullChar
.nShow = 0
.hInstApp = 0
.lpIDList = 0
End With
dRtn = ShellExecuteEx(SEI)
End Sub

The result of this code is the program (Wordpad.exe) starts and shows
in the Task Manager, but never opens up on the desktop. I never see
the window, and I can't even start Wordpad.exe manually until I end
the process from the Task Manager.

Can someone give me a good, working example of ShellExecuteEx?

Shell (yes, that's my name)

From: neilanessa on
Shell,
Here is a link to an ancient posting of something I slam dunked in 2002
;-)
HTH. Neila
http://groups.google.com/group/microsoft.public.vb.winapi/browse_frm/thread/9476f7a66db69ba5/0823a740e32c76fb?lnk=st&q=ShellExecuteEx+Neila&rnum=1&hl=en#0823a740e32c76fb


Shell wrote:
> OK, I've tried everything I can think of to make this work. Even some
> suggestions from Google searches that specify that to make it work I
> have to pass the user type (SHELLEXECUTEINFO) ByVal instead of
> ByRef...which of course will not work.
>
> The Code snippets follow:
>
> <In the Main.bas>
>
> Public Const SEE_MASK_CLASSKEY As Long = &H3
> Public Const SEE_MASK_CLASSNAME As Long = &H1
> Public Const SEE_MASK_CONNECTNETDRV As Long = &H80
> Public Const SEE_MASK_DOENVSUBST As Long = &H200
> Public Const SEE_MASK_FLAG_DDEWAIT As Long = &H100
> Public Const SEE_MASK_FLAG_NO_UI As Long = &H400
> Public Const SEE_MASK_HOTKEY As Long = &H20
> Public Const SEE_MASK_ICON As Long = &H10
> Public Const SEE_MASK_IDLIST As Long = &H4
> Public Const SEE_MASK_INVOKEIDLIST As Long = &HC
> Public Const SEE_MASK_NOCLOSEPROCESS As Long = &H40
>
> Public Type SHELLEXECUTEINFO
> cbSize As Long
> fMask As Long
> hWnd As Long
> lpVerb As String
> lpFile As String
> lpParameters As String
> lpDirectory As String
> nShow As Long
> hInstApp As Long
> lpIDList As Long
> lpClass As String
> hkeyClass As Long
> dwHotKey As Long
> hIcon As Long
> hProcess As Long
> End Type
>
> Public SEI As SHELLEXECUTEINFO
>
> Public Declare Function ShellExecuteEx Lib "shell32.dll" ( _
> SEI As SHELLEXECUTEINFO) As Long
>
> <In the Form's code>
>
> Private Sub Open_Click()
> Dim dRtn As Long, srcFile As String, SEI As SHELLEXECUTEINFO
>
> dRtn = 0
> With SEI
> 'Set the structure's size
> .cbSize = Len(SEI)
> 'Seet the mask
> .fMask = SEE_MASK_NOCLOSEPROCESS Or _
> SEE_MASK_INVOKEIDLIST Or SEE_MASK_FLAG_NO_UI
> 'Set the owner window
> .hWnd = Me.hWnd
> 'Show the properties
> .lpVerb = "Open"
> 'Set the filename
> .lpFile = Me.RTB.FileName
> .lpParameters = vbNullChar
> .lpDirectory = vbNullChar
> .nShow = 0
> .hInstApp = 0
> .lpIDList = 0
> End With
> dRtn = ShellExecuteEx(SEI)
> End Sub
>
> The result of this code is the program (Wordpad.exe) starts and shows
> in the Task Manager, but never opens up on the desktop. I never see
> the window, and I can't even start Wordpad.exe manually until I end
> the process from the Task Manager.
>
> Can someone give me a good, working example of ShellExecuteEx?
>
> Shell (yes, that's my name)

From: Steve Gerrard on

<neilanessa(a)msn.com> wrote in message
news:1164612074.734013.190070(a)f16g2000cwb.googlegroups.com...
> Shell,
> Here is a link to an ancient posting of something I slam dunked in 2002
> ;-)
> HTH. Neila
> http://groups.google.com/group/microsoft.public.vb.winapi/browse_frm/thread/9476f7a66db69ba5/0823a740e32c76fb?lnk=st&q=ShellExecuteEx+Neila&rnum=1&hl=en#0823a740e32c76fb
>
>
> Shell wrote:
>> OK, I've tried everything I can think of to make this work. Even some
>> suggestions from Google searches that specify that to make it work I
>> have to pass the user type (SHELLEXECUTEINFO) ByVal instead of
>> ByRef...which of course will not work.
>>
>> The Code snippets follow:
>>
>> .nShow = 0
>>
>> The result of this code is the program (Wordpad.exe) starts and shows
>> in the Task Manager, but never opens up on the desktop. I never see
>> the window, and I can't even start Wordpad.exe manually until I end
>> the process from the Task Manager.
>>

I think the difference in Neila's post is that
.nShow = 1
i.e. it asks for the window to be shown :)


From: neilanessa on
Yeah,
I knew that. Was hoping Shell would research the structure and go
AHA!!!
Neila

Steve Gerrard wrote:
> <neilanessa(a)msn.com> wrote in message
> news:1164612074.734013.190070(a)f16g2000cwb.googlegroups.com...
> > Shell,
> > Here is a link to an ancient posting of something I slam dunked in 2002
> > ;-)
> > HTH. Neila
> > http://groups.google.com/group/microsoft.public.vb.winapi/browse_frm/thread/9476f7a66db69ba5/0823a740e32c76fb?lnk=st&q=ShellExecuteEx+Neila&rnum=1&hl=en#0823a740e32c76fb
> >
> >
> > Shell wrote:
> >> OK, I've tried everything I can think of to make this work. Even some
> >> suggestions from Google searches that specify that to make it work I
> >> have to pass the user type (SHELLEXECUTEINFO) ByVal instead of
> >> ByRef...which of course will not work.
> >>
> >> The Code snippets follow:
> >>
> >> .nShow = 0
> >>
> >> The result of this code is the program (Wordpad.exe) starts and shows
> >> in the Task Manager, but never opens up on the desktop. I never see
> >> the window, and I can't even start Wordpad.exe manually until I end
> >> the process from the Task Manager.
> >>
>
> I think the difference in Neila's post is that
> .nShow = 1
> i.e. it asks for the window to be shown :)

From: Shell on
In response to the post:
On Mon, 27 Nov 2006 03:08:51 -0800, "Steve Gerrard"
<mynamehere(a)comcast.net> stated...and I replied:

>> Shell wrote:
>>> OK, I've tried everything I can think of to make this work. Even some
>>> suggestions from Google searches that specify that to make it work I
>>> have to pass the user type (SHELLEXECUTEINFO) ByVal instead of
>>> ByRef...which of course will not work.
>>>
>>> The Code snippets follow:
>>>
>>> .nShow = 0
>>>
>>> The result of this code is the program (Wordpad.exe) starts and shows
>>> in the Task Manager, but never opens up on the desktop. I never see
>>> the window, and I can't even start Wordpad.exe manually until I end
>>> the process from the Task Manager.
>>>

><neilanessa(a)msn.com> wrote in message
>news:1164612074.734013.190070(a)f16g2000cwb.googlegroups.com...
>> Shell,
>> Here is a link to an ancient posting of something I slam dunked in 2002
>> ;-)
>> HTH. Neila
>> http://groups.google.com/group/microsoft.public.vb.winapi/browse_frm/thread/9476f7a66db69ba5/0823a740e32c76fb?lnk=st&q=ShellExecuteEx+Neila&rnum=1&hl=en#0823a740e32c76fb
>>
>>

>
>I think the difference in Neila's post is that
> .nShow = 1
>i.e. it asks for the window to be shown :)
>

Thank you much Neila, and <g> thanks for the obvious too Steve.

What gets me is how MS hides (by not fully describing) their API's
usages. I've got the API Guide v3.7, but it showed only the example
MS uses for getting the "properties" form under the ShellExecuteEx.

Now that I've had my nose pointed to the nShow parameter, I spent
about 45 minutes looking for the SW_ Constants. I found them not in
the MSDN or in any MS publication, but in the API Guide under the
ShowWindow's Classical example. And, I must say, the API Guide has
been my most productive resource.

Now I'm looking into the fMask value (SEE_MASK_DOENVSUBST) that will
expand Environment variables in the FileName parameter. This will
allow me to use the Registry entries that point to applications using
%ProgramFiles%. At least I hope that's what I'll be able to do ;)

Shell
 |  Next  |  Last
Pages: 1 2 3 4
Prev: Disk Imaging Utility
Next: MSComm and a Scanner