Groan: FindExecutable can fail on Win8+
Posted: Sat Mar 05, 2016 5:44 pm
Well, FindExecutable() was a great way to test if a PDF Reader existed, but not any more. Windows 8.1/10 associates .pdf with the "modern interface" Reader, even if the Desktop version of Adobe Reader is also installed. So the following tried and trusted code doesn't cut it anymore:
I imagine that 101 out 100 Users prefer the Adobe Desktop Reader over the 'Modern' Reader, which takes over your screen and generally behaves badly, so I don't mind my app telling the User that a PDF Reader can't be found, at least for now. I suspect though that 'Modern' Reader might evolve quickly to become 'only' Reader. Then what....... 
Code: Select all
Procedure.i PdfReaderFind()
;#-------------------------
;Returns a value greater than 32 if successful
Protected sTestFile.s = "test.pdf"
Protected sDir.s = GetTemporaryDirectory()
Protected sExePath.s = Space(#MAX_PATH)
Protected iReaderExists.i = 0
If CreateFile(0, sDir + sTestFile)
CloseFile(0)
iReaderExists = FindExecutable_(sDir + sTestFile, #Null, @sExePath)
DeleteFile(sDir + sTestFile)
EndIf
ProcedureReturn(iReaderExists)
EndProcedure
Debug PdfReaderFind()
