Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I ensure ShellExecute() will print a pdf in windows 10?

API Functions

How can I ensure ShellExecute() will print a pdf in windows 10?

by  ChrisRChamberlain  Posted    (Edited  )
If you are running VFP on Windows 10, one of the 'gotchas' of which to be wary, is Windows 10 resetting the default applications for various file extensions.

The default application for pdf in Windows 10 is Microsoft Edge so if you use the 'print' parameter with the WinAPI call ShellExecute() with that file association in place, the pdf will not print.

The return value from ShellExecute() will be 31, API_ERROR() returning the string "The file type has no associated application" for that value.

One option is to block Window 10's attempts to reset the default applications for the pdf file extension.

First ensure pdfs will print correctly from your chosen pdf viewer/application when set as the default application in Windows 10.

Then, in regedit.exe, navigate to:-
[code ]HKEY_CURRENT_USER\SOFTWARE\Classes\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723[/code]

Add create a new string value here named NoOpenWith and don't set its value data (leave it empty):-
Code:
NoOpenWith=""

It's all neatly explained [link http://winaero.com/blog/prevent-windows-10-from-resetting-your-default-apps/]here[/link], together with original code and other options.

So, from now on, Windows 10 resetting behaviour should not impact on your VFP apps.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top