views:

620

answers:

1

We have a piece of software that attempts to print .tif images using a ProcessStartInfo object. It sets the Verb property to "print" and the FileName property to the path of the image. It then sets the UseShellExecute property to true and executes the Process.Start() method.

However, nothing happens. I created a small test program to list the Verbs associated with .tif images and it only shows "Shell", but not "print".

I cannot modify this piece of software, so is there a way to define or register the "print" verb for .tif image types to allow them to print?

+2  A: 

First of all, the verb you're probably looking for is probably printto

You could also shell execute the print command directly, with

"%SystemRoot%\System32\rundll32.exe" "%SystemRoot%\System32\shimgvw.dll",ImageView_PrintTo /pt "%1" "%2" "%3" "%4"

The parameters are explained in KB224961 as:

%1  File name
%2  Printer name
%3  Driver name
%4  Port name
/p  Print
pt  Printto
Factor Mystic
That's not available either. The Verbs property only shows Shell as being available for the .tif types. Also, like I said, I can't modify this code in any way.
NYSystemsAnalyst
@NYSA - Is the printto verb present in the system that you're having a problem with? I think you'll find that it's missing and needs to be created.
overslacked
OK. I used the Tools -> Folder Options -> File Types to add the TIF file type. For the file type, under Advanced, I added a "print" action and used the command posted above. However, when I try to print through a test application, or through the right-click context menu, I receive an Access Denied message. Any ideas what access is denied to?
NYSystemsAnalyst
How are you determining that "shell" is a verb? You can check manually what the verbs are with regedit.exe... Go to HKEY_CLASSES_ROOT\.tif and note the default value. Then go to HKEY_CLASSES_ROOT\<that default value>\shell and note what the subkeys are. Those are your verbs. What is the default value for the \command subkey for anything that looks like printing? That's what's being invoked by that verb, that's (probably) what's reporting access denied.
Factor Mystic
Thank you for pointing me to that registry key. That was it. I had to find the TIF.ImageDocument key, then, I had to add a key to the shell for "print" with the same value as "printto", but using the /p instead of /pt switch, and removing the %3 and %4 parameters. This seems to have the application working.
NYSystemsAnalyst
Sorry, it was the TIFImage.Document key.
NYSystemsAnalyst