Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Application path retrieval from registry
Message
From
08/08/2001 04:37:48
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
08/08/2001 04:15:59
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00541125
Message ID:
00541130
Views:
34
>Hi
>
>Using the registry.vcx that ships with VFP 6.0, I would like to return the path\filename and therefore verify the existence of a known and registered executable such as "winword.exe".
>
>I assume its a call to filereg.getapplication(), but am having problems in determining the correct code.
>
>TIA
>
>Dennis

Dennis,
This is a simplified version of sample in solution.app (modified to hide complexity) :
LOCAL cExtn,cAppKey,cAppName
LOCAL oReg,regfile
cAppKey = ""
cAppName = ""
oReg = NewObject("FileReg",HOME()+"FFC\registry.vcx")

* Get Application
nErrNum = oReg.GetAppPath('DOC',@cAppKey,@cAppName)

* Remove switches here (i.e., C:\EXCEL\EXCEL.EXE /e)
IF ATC(".EXE",m.cAppName) #0
	m.cAppName= ALLTRIM(SUBSTR(m.cAppName,1,ATC(".EXE",m.cAppName)+3))
	IF ASC(LEFT(cAppName,1))=34	&&check for long file name in quotes
		m.cAppName = SUBSTR(m.cAppName,2)
	ENDIF
ENDIF
? 'App:',LOWER(m.cAppName)
? 'Version:', RIGHT(m.cAppKey,1)
Also if your main concern is to check if a class is registered rather than to know its path (ie:if createobject('word.application') would work or not) then you could also use this :
*Function IsClassRegistered
lparameters tcClass
#DEFINE HKEY_CLASSES_ROOT    -2147483648
#DEFINE ERROR_SUCCESS	0  && OK

DECLARE Integer RegOpenKey IN Win32API ;
	Integer nHKey, String @cSubKey, Integer @nResult

DECLARE Integer RegCloseKey IN Win32API ;
	Integer nHKey

local lnKey
lnKey = 0
llRetVal = ( RegOpenKey(HKEY_CLASSES_ROOT, tcClass, @lnKey) = ERROR_SUCCESS )
if llRetVal
  RegCloseKey(lnKey)
endif
return llRetVal
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform