Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find path for a file
Message
From
12/07/2001 04:16:23
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00529148
Message ID:
00529583
Views:
10
This message has been marked as the solution to the initial question of the thread.
Fabian,
I see...
I think there's a much easier and faster way to retrieve an application's path:
?GetAppPath("ZIP")
Here's the code for GetAppPath(). It uses the registry class that ships with VFP. This works fine as long as an app is registered. This should be much faster than trying to locate an app on all drives.
PROCEDURE GetAppPath(tcExtension)

	*-- returns the application path from the registry

	LOCAL loReg, lcAppKey, lcAppPath, lnErrNum

	loReg       = NEWOBJECT("FileReg", HOME() + "ffc\registry")
	lcAppKey    = ""
	lcAppPath   = ""
	lnErrNum    = loReg.GetAppPath(tcExtension, @lcAppKey, @lcAppPath)

	RELEASE loReg

	IF lnErrNum  0
		*??CHR(7)
		*WAIT WINDOW NOWAIT "Could not determine associated program for '" + tcExtension +"'"
		RETURN ""
	ELSE
		*-- return path only (e.g. remove stuff like %1, /e, etc.)
		RETURN SUBSTR(lcAppPath, 1, ATC(".EXE", lcAppPath) + 4)
	ENDIF

ENDPROC
HTH

>I've already solved my problem.
>
>I wanted to know where WinZip32 is installed. why? To be able to execute it... I need to distribute the app so I can't hardcode the winzip path.
>So now, I get all the hard disks letters, then check them out until I find the exe file...
>if not, it raises an error.
>
>after i get the full path , I use it with APPRUN API to zip files...
>
>ok?
>
>fabian
Daniel
Previous
Reply
Map
View

Click here to load this message in the networking platform