Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Verify file extension is associated with an application
Message
From
13/11/2001 17:20:33
 
 
To
13/11/2001 17:11:15
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00581172
Message ID:
00581183
Views:
20
This message has been marked as the solution to the initial question of the thread.
Malcolm,
You could use something like this:
lcAppPath = GtAppPath("DOC")
IF EMPTY(lcAppPath)
  *-- no app associated
ELSE
  *-- there's an associated app
  *-- check if the file exists
  IF FILE(lcAppPath)
    *-- app exists
  ELSE
    *-- app not found
  ENDIF
 
ENDIF

************************************************
FUNCTION GtAppPath
************************************************
LPARAMETER tcExtension

#INCLUDE "ffc\registry.h"

LOCAL loReg, lcAppKey, lcAppPath, lnErrNum

SET CLASSLIB TO (HOME() + "ffc\registry") ADDITIVE

loReg       = CREATEOBJECT('FileReg')
lcAppKey    = ""
lcAppPath   = ""
lnErrNum    = loReg.GetAppPath(tcExtension, @lcAppKey, @lcAppPath)

RELEASE loReg
RELEASE CLASSLIB (HOME() + "ffc\registry")

IF lnErrNum <> 0
	RETURN ""
ELSE
	*-- return path only (e.g. remove stuff like %1, /e, etc.)
	RETURN SUBSTR(lcAppPath, 1, ATC(".EXE", lcAppPath) + 4)
ENDIF
>We would like to programmatically confirm that a program has been associated with a specific file extension before trying to launch the file using the ShellExec API.
>
>By programmatically confirm, I mean that we would like to make sure that:
>
>1. A program has been associated with the given file extension
>
>2. That the referenced program actually exists
>
>We would use this information to enable/disable specific files from being clicked on if a user's workstation didn't have a valid application associated with the file in question.
>
>Any thoughts on how we might do this?
>
>Thanks!
>Malcolm
Daniel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform