Only have Windows 8.1, but here it works if an "app" has been associated to the pdf extension (I don't use the Adobe but the pdf viewer but a viewer from tracker-software) - the return code is 42 (sic!)
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
If iReaderExists>32
Debug PeekS(@sExePath)
EndIf
ProcedureReturn(iReaderExists)
EndProcedure
Debug PdfReaderFind()
Another approach would be to check the registry (see also
here), the following simple code works for my configuration...
Code: Select all
ProcedureDLL.s ReadRegKey(OpenKey.l, SubKey$, Valuename$)
hKey.l = 0
KeyValue$ = Space(255)
Datasize.l = 255
If RegOpenKeyEx_(OpenKey, SubKey$, 0, #KEY_READ, @hKey)
KeyValue$ = "Error Opening Key"
Else
If RegQueryValueEx_(hKey, Valuename$, 0, 0, @KeyValue$, @Datasize)
KeyValue$ = "Error Reading Key"
Else
KeyValue$ = Left(KeyValue$, Datasize - 1)
EndIf
RegCloseKey_(hKey)
EndIf
ProcedureReturn KeyValue$
EndProcedure
Program.s=ReadRegKey(#HKEY_CLASSES_ROOT,".pdf","")
If Program
Debug ReadRegKey(#HKEY_CLASSES_ROOT,".pdf\"+Program+"\ShellNew","Command")
Else
Debug ": ("
EndIf