Re: SHELL Command problem
- From: "Randy Birch" <rgb_removethis@xxxxxxxx>
- Date: Wed, 30 Aug 2006 22:18:38 -0400
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
--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
Please reply to the newsgroups so all can participate.
"David L. Jones" <altzone@xxxxxxxxx> wrote in message
news:1156931926.011688.62220@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Frank Adam wrote:
On 30 Aug 2006 01:12:58 -0700, "David L. Jones" <altzone@xxxxxxxxx>
wrote:
Frank Adam wrote:Ahh sorry, forgot the leading one. I also should have mentioned that
On 29 Aug 2006 23:02:32 -0700, "David L. Jones" <altzone@xxxxxxxxx>
wrote:
I've got a problem with the SHELL command in VB6Yep, Shell is a braindead function loosely based on the ShellExecute
It works fine for executables like this:
shell "notepad.exe"
But when I try to open other file types like TXT I get the error
message:
"Runtime error 5: Invalid procedure call or argument"
So shell "c:\test.txt" won't work for instance.
The target file isn't being used by another app either.
Anyone know what's going on?
API.
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?
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
That works a treat, thanks Frank!
Dave :)
.
- Follow-Ups:
- Re: SHELL Command problem
- From: Frank Adam
- Re: SHELL Command problem
- References:
- SHELL Command problem
- From: David L. Jones
- Re: SHELL Command problem
- From: Frank Adam
- Re: SHELL Command problem
- From: David L. Jones
- Re: SHELL Command problem
- From: Frank Adam
- Re: SHELL Command problem
- From: David L. Jones
- SHELL Command problem
- Prev by Date: Re: directory listing, mp3 files
- Next by Date: Re: MSCOMM and Binary
- Previous by thread: Re: SHELL Command problem
- Next by thread: Re: SHELL Command problem
- Index(es):
Relevant Pages
|