Справочник Пользователя для National Instruments Drums 320685D-01

Скачать
Страница из 211
Chapter 4
Windows 3.1 Compiler/Linker Issues
©
 National Instruments Corporation
4-5
LabWindows/CVI Programmer Reference Manual
You can use the argument types 
char
unsigned char
int
unsigned int
short
unsigned short
long
unsigned long
float
, and 
double
, as well as pointers to 
any type, and arrays of any type. You can use typedefs for these types.
You can use the return types 
void
char
unsigned char
int
unsigned int
short
unsigned short
long
, and 
unsigned long
, as well as pointers to any type. 
You can use typedefs for these types.
You can use the return types float and double only if the DLL is created with a 
Microsoft C compiler, and the functions returning floats or double are declared with the 
cdecl
 calling convention. You do not have to modify the glue code generated for 
functions that return float or double values.
In the DLL header file, enum sizes must be consistent between LabWindows/CVI and the 
compiler for the DLL. 
typedef enum {
No_Error,
Device_Busy,
Device_Not_Found
} ErrorType; 
The size of 
ErrorType
 is 2 bytes in Visual C++, whereas it is 1 byte in 
LabWindows/CVI. To force LabWindows/CVI to treat 
ErrorType
 as 2 bytes, add 
another enum value explicitly initialized to a 2-byte value, such as the following.
ErrorType_Dummy = 32767
If the DLL you are using performs DMA on a buffer you pass to it, you might experience 
a problem. The DLL might attempt to lock the buffer in memory by calling the Windows 
SDK function 
GlobalPageLock
GlobalPageLock
 fails on buffers allocated with the 
Watcom 
malloc
 function that LabWindows/CVI uses in 32-bit mode. 
Write the DLL so that if 
GlobalPageLock
 fails, the DLL attempts to lock the buffer 
with the following code:
int DPMILock (void *buffer, unsigned long size)
{
DWORD base;
unsigned sel, offset;
union _REGS regs;
sel = SELECTOROF(buffer);
offset = OFFSETOF(buffer);
base = GetSelectorBase(sel);
base = base+offset;
regs.x.ax = 0x600; /* DPMI lock memory function */
regs.x.bx = HIWORD(base);
regs.x.cx = LOWORD(base);
regs.x.di = LOWORD(size);
00ProRef.book : 06chap04.fm  Page 5  Monday, March 9, 1998  3:23 PM