PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, September 18, 2022

[FIXED] How to open multiple files in Windows Photoviewer from VB.NET?

 September 18, 2022     photoviewer, printing, vb.net, winforms     No comments   

Issue

Following code in VB.NET opens a OpenFileDialog, user chooses a JPG file, then the program opens WinPhotoViewer for printing selected JPG. OS is Win7

Sub CmdImprimirJPGClick(sender As Object, e As EventArgs)

Dim filePath As String = ""
Dim openFileDialog1 As New OpenFileDialog()

openFileDialog1.Filter = "JPG files (*.jpg , *.jpeg)|*.jpg;*.jpeg|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 1
'openfiledialog1.Multiselect = True   
openFileDialog1.RestoreDirectory = True

If (DialogResult.OK) = openFileDialog1.ShowDialog(Me) Then
        filePath = openFileDialog1.FileName     
Else
        Exit Sub
End If

Dim oProc As New ProcessStartInfo(filePath)

oProc.verb = "Print"
oProc.CreateNoWindow = True
oProc.WindowStyle = ProcessWindowStyle.Hidden
Process.Start(oProc)

Problem is. Now I want to open MULTIPLE JPG files, and to show the print dialog directly, for printing all of them, on a single page as thumbs, or in many pages. Goal is to print multiple jpgs WITH photoviewer.. how can I do this?, tried putting many filenames in the start String, like "1.jpg" "2.jpg" , but didn't work.

Now I'm trying with a cmd-line:

rundll32 "%ProgramFiles%\Windows Photo Viewer\Photoviewer.dll", ImageView_Fullscreen c:\1.jpg & c:\2.jpg

does opens multiple files (but at different instances), but now I need to apply the Print Switch command, and cmd-line switches for photoviewer.dll seems not to be documented..


Solution

Unless the program allows command line switches to do what your want (which I highly doubt)(check 'Photoviewer.dll ?' or 'Photoviewer.dll /?'), you will have to do this through something like Sendkeys which is not real reliable. But, this all gets MUCH harder when you want to do this with multiple files and the app launches multiple instances of the application.

You used Process.Start() which is good because it will give you the handle to the application that started but it sounds like it started multiple applications with multiple handles, not good. I would suggest you do process.start for each file, use sendkeys, wait for application to close, then process.start the next file.



Answered By - Steve
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing