Shell Doesn't Work With UNC - Can't Get ShellExecute to Work Either

J

jhcoxx

Problem: Need to display in the Windows Picture and Fax Viewer a .png
file that resides on a server - and I can't count on every user having
..png's associated with that viewer. For a local .png file or one on a
server mapped to a drive letter the following Shell command works:

strCmdLine = "rundll32.exe shimgvw.dll,ImageView_Fullscreen
C:\20060301cskdz-a-p.jpg"
lRetVal = Shell(strCmdLine, vbNormalFocus)

but, since I can't be sure all users will have the server mapped to the
same letter, I need to use a UNC pathname - and Shell can't deal with
UNC paths.
From what I've been able to find, it looks like the ShellExecute API
ought to be what's needed, with the definition of (from
http://support.microsoft.com/kb/170918/en-us)

Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As
String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long


The following table provides descriptions for each parameter:
Parameter Description
----------------------------------------------------------------------------
hwnd Identifies the parent window. This window receives any
message boxes an application produces (for example, for
error
reporting).

lpszOp Points to a null-terminated string specifying the
operation
to perform. This string can be "open" or "print." If this
parameter is NULL, "open" is the default value.

lpszFile Points to a null-terminated string specifying the file
to open.

lpszParams Points to a null-terminated string specifying parameters
passed to the application when the lpszFile parameter
specifies an executable file. If lpszFile points to a
string
specifying a document file, this parameter is NULL.

LpszDir Points to a null-terminated string specifying the default
directory.

FsShowCmd Specifies whether the application window is to be shown
when
the application is opened.

But I've been unable to untangle what parts of

"rundll32.exe shimgvw.dll,ImageView_Fullscreen
C:\20060301cskdz-a-p.jpg"

go into which part of the ShellExecute call.

Anyone know? I've lost track of all the combinations that I've tried
:(
Thanks in advance for any help on this!

James Cox
 
J

jhcoxx

I may have it - will have to check at work tomorrow when I have access
to a file server.

stFile = "c:\20060301cskdz-a-p.jpg"

stFile = "C:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscreen " &
stFile

lRet = apiShellExecute(0&, "Open", "rundll32.exe", _
stFile, vbNullString, 3&)

is doing the trick!

Something about shimgvw.dll only being able to be accessed via
rundll32.exe apparently has something to do with what's considered a
parameter for the exe...

James Cox
 

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

Top