Procedure.s FindExecutable (File.s); Retrieves the name to the executable (.exe) file associated with a specific document file
Protected libid.i, FuncId.i, *mem, Result.s
; http://msdn.microsoft.com/en-us/library/bb776419%28VS.85%29.aspx
libid = OpenLibrary(#PB_Any, "shell32.dll" )
If libid
FuncId = GetFunction(libid, "FindExecutableA" )
If FuncId
*mem = AllocateMemory(#MAX_PATH)
If *mem
If CallFunctionFast(FuncId, @File, #Null, *mem ) > 32
Result = PeekS(*mem, #PB_Any, #PB_Ascii)
EndIf
FreeMemory(*mem)
EndIf
EndIf
CloseLibrary(libid)
EndIf
ProcedureReturn Result
EndProcedure
Debug "C:\Temp\Document.pdf"
Last edited by dige on Wed Dec 08, 2010 9:43 am, edited 1 time in total.
"Daddy, I'll run faster, then it is not so far..."
I prefer to have more control over api calls. Its also more safe for
use with different windows versions... or for futur usage against
deprecated functions...
"Daddy, I'll run faster, then it is not so far..."
I agree with Rings. Except if you are coding your app for older windows version than XP (which doesn't have this function available), there is no point of doing it manually.
MSDN wrote:Returns a value greater than 32 if successful, or a value less than or equal to 32 representing an error.
cas wrote:I agree with Rings. Except if you are coding your app for older windows version than XP (which doesn't have this function available), there is no point of doing it manually.
If you're goin to distribut programs, you'll wonder what Windows versions still in use...
"Daddy, I'll run faster, then it is not so far..."