Quantum Data 801GF Especificaciones Pagina 4

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 40
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 3
Page 4 Model 801GC-ISA & 801GF-ISA Programming Manual
Using Our Dynamic Link Library (DLL) in Your Own Programs
Accessing The Dynamic Link Libraries - DLLs
A Dynamic Link Library (DLL) is a collection of functions your program can link with dynamically. Quantum Data
has created several functions in a DLL called HIA.DLL to assist you with your custom programs.
Open Port - This external function is called to open an ISA port to allow communication between the PC and the
ISA generator.
Port Command - This routine is designed to download a command or a query to the ISA generator. When a query
is sent, this routine will also retrieve a response from the generator.
• Board Init - This function will initialize the ISA generator. Note: This command will erase any custom formats,
images or sequences that are currently downloaded in the generator!
To link to a DLL function in Visual Basic is quite different from the way it is done using C. The key to calling a
function in a DLL from a Visual Basic application is the Declare statement. Like a C prototype, the Visual Basic
Declare statement defines the name of the function, its parameters, the data types of the parameters, and the values
returned by the function. But the Declare statement goes one step further and also defines the name of the DLL in
which the function resides.
Here are three C functions declarations from HIA.DLL and their corresponding Declare statements:
First the C function declarations:
int FAR PASCAL _export port_open (char *portspec, COMM_DATA_TYPE *comm_data);
int FAR PASCAL _export port_command (COMM_DATA_TYPE *comm_data, char *cmd, char *response);
int FAR PASCAL _export port_init (COMM_DATA_TYPE *comm_data, char *cmd, char *response);
Now the Visual Basic Declare statements:
Declare Function port_open Lib ñhia.dllî (ByVal PortSpec as String, Comm_Data as COMM_DATA_TYPE) as Integer
Declare Function port_command Lib ñhia.dllî (Comm_Data as COMM_DATA_TYPE, ByVal cmd as String, ByVal
response as String) as Integer
Declare Function board_init Lib ñhia.dllî (Comm_Data as COMM_DATA_TYPE, ByVal cmd as String, ByVal response
as String) as Integer
Helpful Hints
• These Declare statements should be placed in a global module to allow the functions to be used anywhere in the
application.
Visual Basic does not have the ability to split a statement across multiple source lines. The above Declare
statements were split into multiple lines for readability.
The best location for the DLL file is in the Windows directory, the Windows system directory, the Visual Basic
installation directory or some directory in your path.
Passing Parameters
Passing strings in Visual Basic to a C DLL can sometimes be tricky. Visual Basic does not store strings internally as a
standard null-terminated string. Instead, VB internally manipulates strings using a 4-byte string descriptor. It is
important for the ByVal keyword to be placed on a string parameter in the Declare statement. This allows Visual
Basic to pass a pointer to a null-terminated string instead of a pointer to the string descriptor. Although Visual Basic
allows variable length strings, passing a variable length string in Visual Basic to a DLL passes a pointer to an area
only as long as the current string length. The DLL has no control over the allocation of the string, so there is no way
to extend the string when it is passed using ByVal. This means the size of the response string must be declared before
the external function is called. (i.e. Global response as string * 100)
Passing the name of a structure from VB to an external function will pass a pointer to the structure, just as it is done
in C. To access the Quantum Data DLLs, a COMM_DATA_TYPE structure must be declared. This can be placed in a
module along with the Declare statements.
Type COMM_DATA_TYPE
Vista de pagina 3
1 2 3 4 5 6 7 8 9 ... 39 40

Comentarios a estos manuales

Sin comentarios