i have this code
Is is possible to send the image I want to the program so it will open with it?Code:Dim image As Image = PictureBox1.Image
System.Diagnostics.Process.Start("PictureViewer.exe")
Printable View
i have this code
Is is possible to send the image I want to the program so it will open with it?Code:Dim image As Image = PictureBox1.Image
System.Diagnostics.Process.Start("PictureViewer.exe")
You'd have to save the Image as a file and then pass the path of that file as a second argument to Process.Start. You could create a temp file with IO.Path.GetTempFileName or My.Computer.FileSystem.GetTempFileName.
I take it that you are using Windows XP?
It would be the same as opening a image in any graphics program. They all accept filenames as arguments.
If you are running Vista or need to handle that option too then you will want to use ...
"%ProgramFiles%\Windows Photo Gallery\WindowsPhotoGallery.exe"
How could I open it in picture and fax viewer??? whats this program called?
Ah, I didn't realise that PictureViewer.exe wasn't it. I just opened an image in that viewer and then had a look in the Task Manager and it showed up as rundll32.exe, so the Picture& Fax Viewer itself is a DLL, not an EXE. Exactly which DLL I couldn't say.
What OS are you running?
Here's the syntax for running rundll32.exe.
Code:rundll32.exe <dllname>,<entrypoint> <optional arguments>
Got it working.
Here is the complete syntax for passing an image filepath and name to open with the picture and fax viewer.
rundll32.exe %SystemRoot%\system32\shimgvw.dll,ImageView_Fullscreen C:\SomeFolder\SomePicture.jpg
Do I run this into System.Diagnostics.Process.Start or some other way?Quote:
Originally Posted by RobDog888
Yes, use the Process.Start and fill it in like so.
Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sysDir As String = Environment.GetFolderPath(Environment.SpecialFolder.System).ToString
System.Diagnostics.Process.Start(sysDir & "\rundll32.exe", sysDir & "\shimgvw.dll,ImageView_Fullscreen C:\SomeFolder\SomeImage.jpg")
End Sub
That's accurate Rob, but more verbose than necessary. System.Diagnostics is imported by default and system32 is in the Path environment variable. I guess some users might remove it but assuming they haven't this is enough:Obviously the imagePath can come from wherever you like, including an OpenFileDialog. Nice job tracking down the particulars though.vb.net Code:
Process.Start("rundll32", "shimgvw.dll,ImageView_Fullscreen " & imagePath)
Thanks :)
Yes, true you can shorten the System.Diagnostics part but I think what happened was I was debugging getting it to run and it was puking back at me about paths and files not being found that I just qualified them all to get it working :D
Okay dumb question AGAIN... I need to have a file path as a string to enable it to show my selected picture.... so I would use IO.Path.GetTempFileName() but how to get the temp file name of an image in my picturebox?
Code:Dim imagePath As String = IO.Path.GetTempFileName()
Is the image in your picturebox loaded at runtime or is it a resource image?
The Image in your PictureBox is NOT a file. It's an Image object. If it didn't come from a file in the first place then you have to save it to one. GetTempFileName gives you the path of a uniquely named, empty file. Have you saved your Image to that file?
If you do use a temp file don't forget to delete it afterwards too.