How to programmatically call the Windows Picture and Fax viewer?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm writing a Winforms program in VB, Dot Net 2.0. I have a datagridview on
a form and I've defined a column as a DataGridViewLinkColumn. (I have the
usual programmer's problem. I am not sure what sort of machines this code
will run on so I am shooting for the lowest common demoninator.)

As a minimum, this link is intended to point to image files, most likely
Jpegs and gifs, possibly tiffs. What I have so far works fine with the
Office picture manager. This fires when I click on the link.

Public p As New System.Diagnostics.Process
p = System.Diagnostics.Process.Start("ois.exe", s)

(where s is the content of the link.)

How do I call the Picture and Fax viewer in a similar manner?

(And if anyone wants to be extra helpful, what I would like to do next is
come up with an all pupose routine so that I can generate and view links for
all the most common file types including Word Docs and Adobe pdfs, the view
to be based on the individual machine's defaults and capabilities. Is there
any sort of one-size-fits-all generic call I could use?)

Thanks
 
B. Chernick said:
Public p As New System.Diagnostics.Process
p = System.Diagnostics.Process.Start("ois.exe", s)

(where s is the content of the link.)

How do I call the Picture and Fax viewer in a similar manner?

Written from scratch:

\\\
Imports System.Diagnostics
....
Process.Start( _
Environment.ExpandEnvironmentVariables( _
"%windir%\system32\rundll32.exe " & _
"%windir%\system32\shimgvw.dll,ImageView_Fullscreen " & _
"%windir%\Angler.bmp" _
) _
)
///
 
No good.

I rewrote it slightly so I could view the final string.

s2 = Environment.ExpandEnvironmentVariables( _
"%windir%\system32\rundll32.exe " + _
"%windir%\system32\shimgvw.dll, ImageView_Fullscreen
" + s)
Process.Start(s2)

The final value of the string s2 was:
C:\WINNT\system32\rundll32.exe
C:\WINNT\system32\shimgvw.dll,ImageView_Fullscreen
C:\Data\Pictures\BobCage\100_5432.jpg

I keep getting the error: "The system cannot find the file specified"

Both dlls are present and that is the location of the jpeg.

(I also tried it exactly as you wrote it, changing only the name of the bmp
for one actually in my winnt dir. (No Angler.bmp in my winnt.) Same error.
 
B. Chernick said:
I rewrote it slightly so I could view the final string.

s2 = Environment.ExpandEnvironmentVariables( _
"%windir%\system32\rundll32.exe " + _
"%windir%\system32\shimgvw.dll,
ImageView_Fullscreen
" + s)
Process.Start(s2)

The final value of the string s2 was:
C:\WINNT\system32\rundll32.exe
C:\WINNT\system32\shimgvw.dll,ImageView_Fullscreen
C:\Data\Pictures\BobCage\100_5432.jpg

I keep getting the error: "The system cannot find the file specified"

Both dlls are present and that is the location of the jpeg.

(I also tried it exactly as you wrote it, changing only the name of the
bmp
for one actually in my winnt dir. (No Angler.bmp in my winnt.) Same
error.

Which version of Windows are you using?` "WINNT" reminds me of Windows 2000,
but the Fax and image viewer my sample uses is the viewer which is included
in Windows XP.
 
Windows XP Pro. I agree that the Winnt is a bit odd. This is a company
issued computer with a custom setup but I've had it for months and it seems
fairly normal for the most part. Besides, all the files appear to be in
their normal places. Also I am able to right-click on images and send them
to the viewer so I know it's present and working.
 
B. Chernick said:
Windows XP Pro. I agree that the Winnt is a bit odd. This is a company
issued computer with a custom setup but I've had it for months and it
seems
fairly normal for the most part. Besides, all the files appear to be in
their normal places. Also I am able to right-click on images and send
them
to the viewer so I know it's present and working.

You may want to inspect the file format association in an explorer window
under "Tools" -> "Folder options..." -> "File types" to find out how the
viewer expects to be called.
 
I'm not sure how to answer this one. At the moment all of my image types
default to the Microsoft Office Picture Manager. The P&F Viewer is not used.
If I try to change a file type to user the P&F viewer, I do not get an
'Advanced' options button, I get a 'Restore' button. So I don't have any way
to know how XP treats calls to P&F.
 
Hi,
You should pass arguments separately to Process.Start


string s1= Environment.ExpandEnvironmentVariables(
"%windir%\\system32\\rundll32.exe ");
string s2 = Environment.ExpandEnvironmentVariables(
"%windir%\\system32\\shimgvw.dll,ImageView_Fullscreen " +
fileName);

Process.Start(s1, s2);
 
Thanks. Interesting, but the whole issue's been bypassed. I've found a much
easier way to do what I want, by letting the machine defaults do all the work.

Imports System.Diagnostics
Dim myProcess As New Process
myProcess.StartInfo.FileName = s
myProcess.StartInfo.Verb = "Open"
myProcess.Start()

(Where s is the complete filename and path. )
 
Back
Top