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 open a file, using the default application for that file?

API Functions

How can I open a file, using the default application for that file?

by  EricDenDoop  Posted    (Edited  )
Use the following code to open any (registered) file
Code:
LOCAL lnRetval, lcFile, lcOperation
lcFile = "C:\My Documents\Win32api.doc"
* Right click a file in Windows Explorer to see what other
* operations are available, for example Print

lcOperation = "Open"

DECLARE INTEGER ShellExecute IN SHELL32.DLL ;
INTEGER handle,;
STRING @sFile,;
STRING @lp,;
STRING @dir,;
STRING @dir1,;
INTEGER ncmd
lnRetval = ShellExecute(0, lcOperation, lcFile, "", "", 1)
* Error codes returned by ShellExecute:
* lnRetval = ...
* 2 - Bad Association (e.g., invalid URL)
* 31 - No application association
* 29 - Failure to load application
* 30 - Application is busy
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