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

Testing for presence of DLLs on a PC 1

Status
Not open for further replies.

beedubau

Programmer
Joined
Jan 7, 2003
Messages
97
Location
AU
I would like to use the following code to try to test if required dlls are installed.

Code:
PARAMETERS mydll


DECLARE INTEGER FreeLibrary IN kernel32;
	INTEGER hLibModule

	?isDLLAvailable(mydll)


FUNCTION isDLLAvailable(DllFilename)
LOCAL hModule

hModule = LoadLibrary(DllFilename)
IF hModule > 32
	FreeLibrary(hModule)
	lRetval = .T.
ELSE
	lRetval = .F.
ENDIF
RETURN lRetval
ENDFUNC

When stepping the code I get an error on hModule = LoadLibrary(DllFilename) - LoadLibrary not found().

As a consequence It always returns .T.

Can anyone help with this?

Regards

Bryan
 
Bryan,

You need to write a DECLARE for LoadLibrary, just as you have done for FreeLibrary.

Something like this:

Code:
DECLARE INTEGER LoadLibrary IN kernel32;
    STRING lcFileName

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike,

I've now got some work to do <G>

Bryan
 
As a further and better is there a similar way to test for OCXs loaded.

This routine gives a false on an OCX but its there and it works in the app.

But I'd like to check if its registered after install.

Regards

Bryan
 
Bryan,

The way I do it is to call CREATEOBJECT() for the OCX, but to wrap it in a TRY / CATCH / ENDTRY. It's probably not the most elegant solution, but it works OK for me.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top