> >I've got a problem with the SHELL command in VB6
> >
[quoted text clipped - 16 lines]
> Try ShellExecute("open","c:\test.text",vbnullstring,vbnullstring,1)
> Shellexecute is defined in the API viewer.
Thanks for that.
Gave it a try but the parameters you gave do not match the ShellExecute
API declaration that I copied in from the API Viewer. I got this
declaration:
Public Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As
String, ByVal nShowCmd As Long) As Long
Why the mis-match?
Is there another method?
Thanks
Dave :)
Frank Adam - 30 Aug 2006 10:03 GMT
>> >I've got a problem with the SHELL command in VB6
>> >
[quoted text clipped - 28 lines]
>
>Why the mis-match?
Ahh sorry, forgot the leading one. I also should have mentioned that
the return velue is quite useful, since the function returns larger
than 32 if the operation was succesful and < or = 32 if it failed. If
all is well, the return value is in fact the process ID.
So you should really do it like this :
dim ret as long
ret = ShellExecute(0,"open","c:\test.txt",vbnullstring,vbnullstring,1)
if ret > 32 then
debug.print "Ok"
else
debug.print "Failed. Errno: " & err.lastdllerror
endif

Signature
Regards, Frank
David L. Jones - 30 Aug 2006 10:58 GMT
> >> >I've got a problem with the SHELL command in VB6
> >> >
[quoted text clipped - 42 lines]
> debug.print "Failed. Errno: " & err.lastdllerror
> endif
That works a treat, thanks Frank!
Dave :)
Randy Birch - 31 Aug 2006 03:18 GMT
And if the call does fail, you can have the Open With dialog pop up using:
If success < 32 Then
Call Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " & sFile,
vbNormalFocus)
End If

Signature
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
Please reply to the newsgroups so all can participate.
Frank Adam wrote:
> On 30 Aug 2006 01:12:58 -0700, "David L. Jones" <altzone@gmail.com>
> wrote:
[quoted text clipped - 49 lines]
> debug.print "Failed. Errno: " & err.lastdllerror
> endif
That works a treat, thanks Frank!
Dave :)
Frank Adam - 31 Aug 2006 09:48 GMT
Ha! success <= 32, not success < 32.
Hey Rick, it's ok. I got him back. ;-)
>And if the call does fail, you can have the Open With dialog pop up using:
>
> If success < 32 Then
> Call Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " & sFile,
>vbNormalFocus)
> End If

Signature
Regards, Frank