3 declaring and calling pc9000 sdk dll functions – Campbell Scientific Software Development Kit Beginner's Guide User Manual

Page 18

Advertising
background image

Section 4. PC9000 SDK

4-2

If desired, PC9000.DLL can alternately be located in other directories; for
example, some developers prefer to keep a copy of all key DLL files in the
same subdirectory as the applications program that they create. By locating a
DLL in the same directory as a custom program, multiple DLL versions can
reside on the same machine at the same time. For custom, PC9000.DLL-based
applications, this will not be of any concern unless the computer in question
also runs a copy of PC9000 Version 5.X software. In that case, if the PC9000
V5.X installation uses an older version of PC9000.DLL than the one provided
with this software development kit, and there is some specific concern about
PC9000 DLL compatibility, then keeping a separate copy of the DLL in the
custom application directory may be warranted.

When invoking a DLL function from within a Visual Basic program for the
first time, Windows will look for the DLL in the local subdirectory, and then in
the Windows System directory and in any other subdirectories included in the
PATH environment variable. If it cannot locate the DLL in any of these
directories, VB will raise an Error 53 on the line of code where the first DLL
function is invoked.

4.3 Declaring and Calling PC9000 SDK DLL

Functions

Declaring and using PC9000.DLL functions within a Visual Basic program is
no different than using standard Windows API functions. For general
assistance in calling API functions from within Visual Basic, consult the
applicable Microsoft Visual Basic and/or MSDN documentation. The required
declare statements all appear together in the last section of the PC9000 SDK
manual.

For simplicity, the declare statements are often placed in a code (.BAS) module
of the programmer’s choice. They are then available for use in all form, code,
and class modules within the application. If the DLL functionality is to be
encapsulated within a VB form or class module, declare statements can be
located there, but the “Private” keyword will need to be added at the beginning
of each Declare statement, else the code will not compile. In that case, the
functions will only be usable from routines within the form/class module.

API-style DLL functions don’t raise errors to Visual Basic. The success or
failure of each function must be determined within the Visual Basic program
by evaluating the return codes, as documented in the PC9000 SDK reference.
On the other hand, if fundamental errors occur in linking the DLL function to
the application, the Visual Basic runtime engine will not be able to properly
call the DLL function in the first place. In such cases, runtime errors will be
raised to the application program by the runtime engine itself.

More detailed information regarding DLL usage, function arguments and
return codes can be found in the PC9000 SDK manual.

Advertising