Can someone please tell me why my exe is looking for the full path of my .dll file? I included this file(.dll) in my project. It should be compiled in my exe right? I should not have to specify path, when accessing it.
I use the following routine to load up my FLLs (VFP 6/7), you could make a few minor changes and use it to find your DLLs. Note: GOTFILE() is normally a separate .PRG file.
* LoadLibrary.Prg
PARAMETERS p_cFLLName, p_cMoreInfo
LOCAL l_lRetVal, l_cCurrentPath, l_lWantErrorMsg
l_lWantErrorMsg = IIF(PCOUNT()>1, .T., .F.)
l_lRetVal = .T.
** Make sure library is loaded properly
DO WHILE .T. && not really a loop - just for easy exit
** Make sure FLL not already in SET("Library" **
IF UPPER(ALLTRIM(p_cFLLName)) $ SET("LIBRARY"
l_lRetVal = .T.
IF l_lWantErrorMsg
p_cMoreInfo = "This .FLL: '"+p_cFLLName+"' Already Loaded"
ENDIF
EXIT
ENDIF
** Start where codefile is located **
l_cCurrentPath = ADDBS(ALLTRIM(JUSTPATH(SYS(16))))
IF LEFT(l_cCurrentPath,1) ="\" && fix it
l_cCurrentPath = ".."+l_cCurrentPath
ENDIF
IF !GotFile(l_cCurrentPath+p_cFLLName)
** Now try the HOME() directory **
l_cCurrentPath = ADDBS(ALLTRIM(HOME()))
IF !GotFile(l_cCurrentPath+p_cFLLName)
** Now try the Windows directory **
l_cCurrentPath = ADDBS(ALLTRIM(GETENV('windir')))
IF !GotFile(l_cCurrentPath+p_cFLLName)
** Now try the Windows system directory **
l_cCurrentPath = l_cCurrentPath +"system32\"
IF !GotFile(l_cCurrentPath+p_cFLLName)
** Can't find it in all the usual places **
l_lRetVal = .F.
IF l_lWantErrorMsg
p_cMoreInfo = "Can't Find '"+p_cFLLName+"'"
ENDIF
EXIT
ELSE
IF l_lWantErrorMsg
p_cMoreInfo = "Found '"+p_cFLLName ;
+"' in Windows System Directory"
ENDIF
ENDIF
ELSE
IF l_lWantErrorMsg
p_cMoreInfo = "Found '"+p_cFLLName ;
+"' in Windows Directory"
ENDIF
ENDIF
ELSE
IF l_lWantErrorMsg
p_cMoreInfo = "Found '"+p_cFLLName ;
+"' in HOME() Directory"
ENDIF
ENDIF
ELSE
IF l_lWantErrorMsg
p_cMoreInfo = "Found '"+p_cFLLName ;
+"' in Code File Directory"
ENDIF
ENDIF
l_cCurrentPath = UPPER(l_cCurrentPath)
SET LIBRARY TO (l_cCurrentPath+p_cFLLName) ADDITIVE
EXIT
ENDDO
RETURN l_lRetVal
FUNCTION gotfile
LPARAMETERS p_cFileName
LOCAL l_nAttributes
IF TYPE("p_cFileName" <> "C"
RETURN .F.
ENDIF
* -- Check for existence of the filespec and return <exprL>
DECLARE Integer GetFileAttributes in win32api string lpFileName
#DEFINE FILE_ATTRIBUTE_ARCHIVE 0x20
#DEFINE FILE_ATTRIBUTE_DIRECTORY 0x10
#DEFINE FILE_ATTRIBUTE_HIDDEN 0x02
#DEFINE FILE_ATTRIBUTE_NORMAL 0x80
#DEFINE FILE_ATTRIBUTE_READONLY 0x01
#DEFINE FILE_ATTRIBUTE_SYSTEM 0x04
#DEFINE FILE_ATTRIBUTE_TEMPORARY 0x100
l_nAttributes = GetFileAttributes(p_cFileName)
IF l_nAttributes = -1 ;
OR BITAND(l_nAttributes, FILE_ATTRIBUTE_DIRECTORY) > 0 ;
OR BITAND(l_nAttributes, FILE_ATTRIBUTE_TEMPORARY) > 0
RETURN .F. && not a valid file name
ENDIF
RETURN .T.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.