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

Included .dll in project

Status
Not open for further replies.

Crazyfox

Programmer
Dec 18, 2003
3
US
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.

Any ideas?

 
A DLL cannot be compiled into an EXE. It is always an external file.

Ian
 
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.

Rick

Example usage:
l_cMessage = ""
l_lLoaded = LoadLibrary("foxtools.fll", @l_cMessage)
? l_cMessage


* 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(&quot;p_cFileName&quot;) <> &quot;C&quot;
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.

 
Thanks dude...It seems so messy to go this route. I'll just ship my .dll as external file.

preciate your help though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top