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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is 3rd party app installed? 2

Status
Not open for further replies.

torturedmind

Programmer
Jan 31, 2002
1,052
PH
hi everyone. i hope this is the right forum to post this thread. anyways, i just wanted to ask how can a vfp6 app know if a 3rd party app is already installed or not?

thanks in advanced for any info. peace! [peace]

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
Hi Kilroy,

Does you have any control over the installation of the third-party app? If so, get the setup program to write a registry entry, which your VFP code can check for.

Do you know the directory where the EXE file will be installed? If so, use FILE() to test for the existence of the directory.

Another option: Try to ShellExecute() the application. If it returns a value less than 32, it means it couldn't run. (2 means the EXE file was not found.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Try this

lcFullfilePath = File_Registry("outlook.exe")

Code:
*/***************************************************************************
*#Is File in Windows Registry
*/Program   : File_Registry
*/System    : FoxPro Library
*/Purpose   : Return the full path of a exe file if it is in the windows registry.
*/Syntax    : Path = File_Registry(exefile)
*/Returns   : Path - string - fullpath and name
*/Parameter : exefile - string - application name (with the exe extension)
*/Defaults  : none
*/Requires  : Win9x -> WinXP
*/Changes   : nothing
*/Calls     : External : WinApi AdVapi32.dll
*/Version   : 1.0
*/Dated     : 09/11/2000
*/Written By: David W. Grewe
*/***************************************************************************
*&Application - Utility
*/***************************************************************************
*/ Record Of Change
*/
*/***************************************************************************
*procedure File_Registry
LPARAMETERS pcExeName
* returns full path of EXE file taking it from Windows registry, or empty string

IF	EMPTY(m.pcExeName) OR VARTYPE(m.pcExeName)<>"C" OR PARAMETERS()<1
	RETURN ' '
ENDIF
m.pcExeName = JUSTFNAME(m.pcExeName)

DECLARE LONG RegOpenKey    IN advapi32 LONG hKey, STRING lpSubKey, LONG @phkResult
DECLARE LONG RegQueryValue IN advapi32 LONG hKey, STRING lpSubKey, STRING @lpValue, LONG @lpcbValue
DECLARE LONG RegCloseKey   IN advapi32 LONG hKey
#DEFINE HKEY_LOCAL_MACHINE  -2147483646  && bitset(0,31)+2

LOCAL lnErrorRes, phkResult, lpSubKey, lpValue, lpcbValue

phkResult = 0
lpSubKey = 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths'
lpValue = .NULL.
lpcbValue = 0

lnErrorRes = RegOpenKey(HKEY_LOCAL_MACHINE, lpSubKey, @phkResult)
IF lnErrorRes # 0 OR phkResult = 0        && Cannot open registry key - unknown error
	=MESSAGEBOX('Cannot open Windows registry.',16,'')
	RETURN ''
ENDIF

&& open key for exe
lnErrorRes = RegQueryValue(phkResult, m.pcExeName, @lpValue, @lpcbValue)
IF 	lnErrorRes # 0 OR lpcbValue = 0        && exe-file not registered or path not stored (0 byte length)
	lnErrorRes = RegCloseKey(phkResult)
*  = messagebox('Exe file not registered in Windows.',16,'')
	RETURN ''
ENDIF

lpValue = SPACE(lpcbValue)        && in lpcbValue - size of string
lnErrorRes = RegQueryValue(phkResult, m.pcExeName, @lpValue, @lpcbValue)
IF 	lnErrorRes # 0 OR ISNULL(lpValue) OR EMPTY(lpValue)
&& cannot read default value - unknown error
	lnErrorRes = RegCloseKey(phkResult)
	=MESSAGEBOX('Cannot read value from registry.',16,'')
	RETURN ''
ENDIF

lnErrorRes = RegCloseKey(phkResult)
IF  lnErrorRes # 0
&& cannot close key - ignore this error
ENDIF

&& in lpValue - path for exe
lpValue = CHRTRANC(lpValue, CHR(0), '')        && delete ending #0

RETURN lpValue

David W. Grewe Dave
 
thank you both for the replies and suggestions.

mike:
no my app really doesn't need to install anything or write to the registry. just needed to check if a particular 3rd party app is installed or not. after posting this thread, i went and used shellexecute() which is so far working according to my requirement. thanks again. (ot: btw, as a member of this forum for several years now, i am very very grateful of having you to be one of the first forumsters (is there such a word?) to answer almost all my inquiries. most of your suggestions pointed me to the right track to where i wanted to be. i really dunno how to show my appreciation. maybe i could buy you a beer or two or sumthing.) [cheers]

david:
your code seems to be a promising one. i'll try it and see what comes up. thanks. [thumbsup2]

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top