Printing PDFs

C

cj

In windows explorer if I select a group of pdfs, right click and select
print, the files are printed. I notice it launches Acrobat Reader but
it never asks me anything just prints them.

How can I from within a VB program achieve similar functionality. Say
if I get the directory info on the files I want printed as part of the
vb program and then how do I go about having it print them?

DirInfo = New System.IO.DirectoryInfo(myDir)
FileInfo = DirInfo.GetFiles(mask)
For Each file As System.IO.FileInfo In FileInfo
*print the file
Next
 
W

Walter Wang [MSFT]

Hi cj,

The URL provided by Eric should get you going.

For a background of this shell verb stuff, you can find more information
here:

#Verbs and File Associations
http://msdn2.microsoft.com/en-us/library/aa969385.aspx


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

cj

Yea, but using process/shell leaves me responsible for the right exe and
parameters to print the file. I was hoping there was some way I could
just have VB say print and let windows sort out how to print it. A way
VB could tell windows to print it. Windows Explorer does this
somehow--I'm sure it knows to use Acrobat because it's associated with
the pdf extension. But more importantly how does Windows Explorer
communicates to Acrobat that it should be printed vs opened? That would
be interesting to know.
 
C

cj

Walter, Thanks! Between this and the bottom of Eric's page I think I
have it figured out.

Dim MyProcess As New Process
MyProcess.StartInfo.FileName = "c:\temp\test.pdf"
MyProcess.StartInfo.Verb = "Print"
MyProcess.Start()

But as usual MS has confused me. In reading your msdn link there is no
mention of "process". Msdn seems to suggest shellexecute is a command
used in VB but VB doesn't recognize it. I don't get it. What is the
relationship between shellexecute and system.diagnostics.process?
 
C

cj

Eric, Thanks, I see what I need at the very bottom of the article now.
Please read my response to Walter. If you can help explain the
relationship between system.diagnostics.process and shellexecute it'd be
appreciated.
 
W

Walter Wang [MSFT]

Hi cj,

Verb is a shell concept; CreateProcess doesn't know this verb stuff.

Internally, Process class in .NET is using ShellExecute instead of
CreateProcess (ProcessStartInfo.UseShellExecute default is true).

Yes ShellExecute is an API that doesn't exposted in .NET class library
directly. Besides you're actually using it via Process, you can also use it
directly via P/Invoke:

#pinvoke.net: ShellExecute (shell32)
http://www.pinvoke.net/default.aspx/shell32/ShellExecute.html


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
E

Eric Moreau

Hi

ShellExecute was used in the VB6 era!

Now that we are in .Net, we use the Process component.

--

HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc. (http://www.emoreau.com)
 

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