Download LabWindows/CVI Programmer Reference Manual

Transcript
Chapter 4
Creating and Distributing Standalone Executables and DLLs
You must always distribute DLLs as separate files. The operating system finds the DLL
associated with the loaded import library using the standard Windows DLL search algorithm.
The search precedence is as follows:
1.
The directory from which the application loads
2.
The current working directory
3.
Under Windows 98/95, the Windows system directory. Under Windows 2000/NT, the
Windows system32 and system directories
4.
The Windows directory
5.
The directories the PATH environment variable lists
Using LoadExternalModule on Source Files (.c)
If you pass the name of a source file to LoadExternalModule, the source file must be in
the project. LabWindows/CVI automatically compiles the source file and links it into the
executable when you select Create Debuggable Executable, Create Release Executable,
Create Debuggable Dynamic Link Library, or Create Release Dynamic Link Library.
For this reason you must pass a simple filename to LoadExternalModule. If you use an
external compiler, refer to the Using LoadExternalModule on Files in the Project section
earlier in this chapter.
If the source file is an instrument driver program that is not in the project and you link in
LabWindows/CVI, you have two alternatives:
•
Add the instrument driver .c source to the project.
•
Refer to one of the variables or functions it exports in one of your project files.
If the source file is an instrument program that is not in the project and you link in an external
compiler, you must create an object file and keep it separate from the executable.
Rules for Accessing Other Files
The functions for accessing files, such as fopen, OpenFile, SetFileAttrs, DeleteFile,
and so on, interpret relative pathnames as being relative to the current working directory. The
initial current working directory is normally the directory of the executable. However, if a
different directory exists in the Working Directory or Start In field of the Properties dialog
box for the executable, then it is the initial current working directory. You can create an
absolute path for a file in the executable directory by using GetProjectDir and
MakePathname.
LabWindows/CVI Programmer Reference Manual
4-12
www.ni.com