Chapter 27: Using the Windows Application Programming Interface
943
TABLE 27.1
Comparing C/C++ and VBA Data Types
C Type Size VBA Data Type
char 8 bits String * 1
short 16 bits Integer
int 32 bits Long
long 32 bits Long
float 32 bits Single
double 64 bits Double
UINT 32 bits Long
ULONG 32 bits Long
USHORT 16 bits Integer
UCHAR 8 bits String * 1
DWORD 32 bits Long
BOOL 32 bits Boolean
BYTE 8 bits Byte
WORD 16 bits Integer
HANDLE 32 bits Long
LPTSTR 32 bits No equivalent
LPCTSTR 32 bits No equivalent
All these data types become important when examining both the SDKs and other API references
for VBA. You’ll have to know what kind of data type the function is expecting and match it with a
compatible type in your Access applications. Listing 27.1 shows how the GetPrivateProfile-
String function is declared in the API reference of the Win32 SDK and how to decipher each
argument declared.
LISTING 27.1
SDK Reference for GetPrivateProfileString
DWORD GetPrivateProfileString(
LPCTSTR lpszSection, // points to section name
LPCTSTR lpszKey, // points to key name
LPCTSTR lpszDefault, // points to default string
LPTSTR lpszReturnBuffer, // points to destination buffer
DWORD cchReturnBuffer, // size of destination buffer
LPCTSTR lpszFile // initialization filename
);