引子:昨天在用vb调用vc写的dll文件的时候,变量的使用上出现了问题,通过反编译调试,发现vb中的long才是对应c中的int。而不是integer对应int。
以下是找到的资料:
在本篇中我们重点讲讲Api函数声明中参数列表的部分.
我们知道每种编程语言的数据类型都不尽相同,比如说C中的int和VB中的integer,看名字它们都是整型,但是它们占有的内存单元却是完全不同的.VB中的Integer是占用2个字节的.所以如果某个Api函数原型是C的int型你用Integer去声明它的话,会产生一些意外的错误.正确的做法是用Long去声明它.下面我们例出一些常用的类型转换:
C语言类型 | VB类型 | Bytes |
const char* | Long | 4 |
__int16 | Integer | 2 |
__int32 | Long | 4 |
__int64 | Double | 8 |
__int8 | Byte | 1 |
bool | Long | 4 |
float | Single | 4 |
double | Double | 8 |
short | Integer | 2 |
int | Long | 4 |
char | Byte | 1 |
unsigned int | Long | 4 |
char | Byte | 1 |
unsigned char | Byte | 1 |
unsigned char | Byte | 1 |
unsigned short | Integer | 2 |
unsigned int | Long | 4 |
VARIANT_BOOL | Integer | 2 |
wchar_t | Integer | 2 |
FARPROC | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
LONG | Long | 4 |
DWORD | Long | 4 |
WORD | Integer | 2 |
WORD | Integer | 2 |
WORD | Integer | 2 |
WCHAR/BYTE | integer/byte | 2/1 |
DWORD | Long | 4 |
unsigned long int | Long | 4 |
int | Long | 4 |
unsigned char | Byte | 1 |
unsigned char | Byte | 1 |
OLECHAR* | Long | 4 |
unsigned char | Byte | 1 |
unsigned char | Byte | 1 |
DWORD | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
DWORD | Long | 4 |
char | Byte | 1 |
char | Byte | 1 |
WORD | Integer | 2 |
long | Long | 4 |
void* | Long | 4 |
CMC_sint32 | Long | 4 |
CMC_uint32 | Long | 4 |
CMC_uint32 | Long | 4 |
CMC_uint32 | Long | 4 |
short | Integer | 2 |
long int | Long | 4 |
char | Byte | 1 |
char* | Long | 4 |
CMC_uint32 | Long | 4 |
unsigned short int | Integer | 2 |
unsigned long int | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
CY | Long | 4 |
int | Long | 4 |
DWORD | Long | 4 |
LONG | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
float | Single | 4 |
double | Double | 8 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
WORD | Integer | 2 |
DWORD | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
CHAR | Byte | 1 |
DESKTOPENUMPROCA | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
unsigned int | Long | 4 |
PVOID | Long | 4 |
LONG | Long | 4 |
FARPROC | Long | 4 |
double | Double | 8 |
double | Double | 8 |
DWORD | Long | 4 |
FARPROC | Long | 4 |
DWORD | Long | 4 |
unsigned long | Long | 4 |
unsigned __int64 | Double | 8 |
EDITWORDBREAKPROCA | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
unsigned long | Long | 4 |
INT | Long | 4 |
* | Long | 4 |
BYTE | Byte | 1 |
int | Long | 4 |
WORD | Integer | 2 |
unsigned long | Long | 4 |
float | Single | 4 |
float | Single | 4 |
DWORD | Long | 4 |
FONTENUMPROCA | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
ULONG | Long | 4 |
__int64 | Double | 8 |
WORD | Integer | 2 |
void* | Long | 4 |
long | Long | 4 |
long | Long | 4 |
HANDLE | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
unsigned int | Long | 4 |
HANDLE | Long | 4 |
ULONG | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
PVOID | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
ULONG | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
LPVOID | Long | 4 |
void* | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HICON | Long | 4 |
void* | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
PVOID | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
DWORD | Long | 4 |
void* | Long | 4 |
HANDLE | Long | 4 |
void* | Long | 4 |
int | Long | 4 |
HANDLE | Long | 4 |
ULONG | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
struct _IMAGELIST NEAR* | Long | 4 |
DWORD | Long | 4 |
DWORD | Long | 4 |
HANDLE | Long | 4 |
PVOID | Long | 4 |
HANDLE | Long | 4 |
LPVOID | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
void* | Long | 4 |
void* | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
void* | Long | 4 |
HGLOBAL | Long | 4 |
FARPROC | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
DWORD | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
DWORD | Long | 4 |
LONG | Long | 4 |
HANDLE | Long | 4 |
ULONG | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
WORD | Integer | 2 |
PVOID | Long | 4 |
PVOID | Long | 4 |
void* | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
struct _TREEITEM FAR* | Long | 4 |
ULONG | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
HANDLE | Long | 4 |
__int64 | Double | 8 |
void* | Long | 4 |
void* | Long | 4 |
unsigned short | Integer | 2 |
int | Long | 4 |
int | Long | 4 |
WORD | Integer | 2 |
ULONG | Long | 4 |
LONG | Long | 4 |
int | Long | 4 |
WORD | Integer | 2 |
WORD | Integer | 2 |
LONGLONG | Double | 8 |
DWORD | Long | 4 |
LONG | Long | 4 |
LONG | Long | 4 |
DWORD | Long | 4 |
unsigned long | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
HANDLE | Long | 4 |
long | Long | 4 |
long | Long | 4 |
long double | Double | 8 |
long | Long | 4 |
__int64 | Double | 8 |
hyper | Double | 8 |
long | Long | 4 |
IAuthenticate* | Long | 4 |
IBindCtx* | Long | 4 |
union tagBINDPTR* | Long | 4 |
BOOL* | Long | 4 |
LPRECT | Long | 4 |
unsigned char* | Long | 4 |
LPCRECT | Long | 4 |
const CHAR* | Long | 4 |
const DLGTEMPLATE* | Long | 4 |
const DLGTEMPLATE* | Long | 4 |
const FOLDERSETTINGS* | Long | 4 |
CHAR* | Long | 4 |
const IID* | Long | 4 |
const ITEMIDLIST* | Long | 4 |
CLSID* | Long | 4 |
MENUITEMINFOA const* | Long | 4 |
MENUITEMINFOW const* | Long | 4 |
const MMCKINFO* | Long | 4 |
const MMIOINFO* | Long | 4 |
const OLECHAR* | Long | 4 |
DWORD* | Long | 4 |
const PROPSHEETHEADERA* | Long | 4 |
const PROPSHEETHEADERW* | Long | 4 |
const PROPSHEETPAGEA* | Long | 4 |
const PROPSHEETPAGEW* | Long | 4 |
REBARBANDINFOA const* | Long | 4 |
REBARBANDINFOW const* | Long | 4 |
const RECT* | Long | 4 |
const RECTL* | Long | 4 |
PRTL_CRITICAL_SECTION | Long | 4 |
SCROLLINFO const* | Long | 4 |
const SHITEMID* | Long | 4 |
const CHAR* | Long | 4 |
const TBBUTTON* | Long | 4 |
const TCHAR* | Long | 4 |
const void* | Long | 4 |
const WAVEFORMATEX* | Long | 4 |
const WCHAR* | Long | 4 |
const WCHAR* | Long | 4 |
DWORD* | Long | 4 |
DWORD* | Long | 4 |
DWORD* | Long | 4 |
D3DCOLORMODEL* | Long | 4 |
DWORD* | Long | 4 |
DWORD* | Long | 4 |
DWORD* | Long | 4 |
float* | Long | 4 |
DESC_CHAR* | Long | 4 |
DLGITEMTEMPLATE* | Long | 4 |
DLGITEMTEMPLATE* | Long | 4 |
DLGTEMPLATE* | Long | 4 |
DLGTEMPLATE* | Long | 4 |
DWORD* | Long | 4 |
DWORD* | Long | 4 |
SBinaryArray* | Long | 4 |
IEnumCATEGORYINFO* | Long | 4 |
PFIBER_START_ROUTINE | Long | 4 |
FMTID* | Long | 4 |
ACCELERATEABSDI* | Long | 4 |
DISMISSMODELESS* | Long | 4 |
long* | Long | 4 |
long* | Long | 4 |
GUID* | Long | 4 |
HANDLE* | Long | 4 |
IID* | Long | 4 |
int* | Long | 4 |
WORD* | Long | 4 |
unsigned long* | Long | 4 |
long* | Long | 4 |
VOID** | Long | 4 |
PVOID | Long | 4 |
PVOID | Long | 4 |
DWORD* | Long | 4 |
NMSELCHANGE* | Long | 4 |
OLECHAR* | Long | 4 |
WORD* | Long | 4 |
const char** | Long | 4 |
LPMAPIFORMINFO* | Long | 4 |
SIZE* | Long | 4 |
CHAR* | Long | 4 |
IStream* | Long | 4 |
LPSTR | Long | 4 |
PTHREAD_START_ROUTINE | Long | 4 |
LPSTR | Long | 4 |
unsigned long* | Long | 4 |
VARIANT* | Long | 4 |
LPBYTE | Long | 4 |
void* | Long | 4 |
WCHAR* | Long | 4 |
WORD* | Long | 4 |
WCHAR* | Long | 4 |
LONG | Long | 4 |
unsigned long | Long | 4 |
DWORD | Long | 4 |
long | Long | 4 |
unsigned long | Long | 4 |
char | Byte | 1 |
unsigned long | Long | 4 |
LARGE_INTEGER | Double | 8 |
int | Long | 4 |
DISPID | Long | 4 |
double | Double | 8 |
DWORD | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
void* | Long | 4 |
CHAR* | Long | 4 |
LONG | Long | 4 |
WCHAR* | Long | 4 |
long | Long | 4 |
FARPROC | Long | 4 |
VARIANT_BOOL | Integer | 2 |
DWORD | Long | 4 |
VARIANT_BOOL | Integer | 2 |
UINT | Long | 4 |
VARIANT_BOOL | Integer | 2 |
float | Single | 4 |
LONG | Long | 4 |
long | Long | 4 |
float | Single | 4 |
LONG | Long | 4 |
long | Long | 4 |
float | Single | 4 |
LONG | Long | 4 |
long | Long | 4 |
float | Single | 4 |
LONG | Long | 4 |
long | Long | 4 |
WCHAR | Integer | 2 |
ACL* | Long | 4 |
WORD | Integer | 2 |
IAVIEditStream* | Long | 4 |
IAVIFile* | Long | 4 |
IAVIStream* | Long | 4 |
IAVIStreaming* | Long | 4 |
WORD* | Long | 4 |
BOOL* | Long | 4 |
BOOLEAN* | Long | 4 |
BYTE* | Long | 4 |
const CHAR* | Long | 4 |
COMBOBoxEXITEMA const* | Long | 4 |
COMBOBoxEXITEMW const* | Long | 4 |
CHAR* | Long | 4 |
CHAR* | Long | 4 |
const IUniformResourceLocatorA* | Long | 4 |
IConnectionPoint* | Long | 4 |
IConnectionPointContainer* | Long | 4 |
PRTL_CRITICAL_SECTION | Long | 4 |
const CHAR* | Long | 4 |
char* | Long | 4 |
const URLINVOKECOMMANDINFOA* | Long | 4 |
const URLINVOKECOMMANDINFOW* | Long | 4 |
const WCHAR* | Long | 4 |
const WCHAR* | Long | 4 |
LONG | Long | 4 |
DLGITEMTEMPLATE* | Long | 4 |
DLGITEMTEMPLATE* | Long | 4 |
DWORD* | Long | 4 |
DWORDLONG* | Long | 4 |
IEnumConnectionPoints* | Long | 4 |
IEnumConnections* | Long | 4 |
FLOAT* | Long | 4 |
const unsigned char* | Long | 4 |
IGetFrame* | Long | 4 |
HANDLE* | Long | 4 |
HKEY* | Long | 4 |
int* | Long | 4 |
IUniformResourceLocatorA* | Long | 4 |
LARGE_INTEGER* | Long | 4 |
PDWORD | Long | 4 |
long* | Long | 4 |
LONGLONG* | Long | 4 |
LUID* | Long | 4 |
const MIDL_STUB_DESC* | Long | 4 |
void* | Long | 4 |
LONG* | Long | 4 |
WORD | Integer | 2 |
PROPENUMPROCA | Long | 4 |
FARPROC | Long | 4 |
PROPENUMPROCEXA | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
ULONG | Long | 4 |
SCODE* | Long | 4 |
WORD* | Long | 4 |
DWORD* | Long | 4 |
SHORT* | Long | 4 |
PVOID | Long | 4 |
SIZE* | Long | 4 |
CHAR* | Long | 4 |
char* | Long | 4 |
unsigned char* | Long | 4 |
LPSTR | Long | 4 |
char* | Long | 4 |
void* | Long | 4 |
int | Long | 4 |
LPSTR | Long | 4 |
UCHAR* | Long | 4 |
unsigned int* | Long | 4 |
ULONG* | Long | 4 |
ULONGLONG* | Long | 4 |
USHORT* | Long | 4 |
void* | Long | 4 |
WCHAR* | Long | 4 |
WCHAR* | Long | 4 |
WORD* | Long | 4 |
WSH_NBP_NAME* | Long | 4 |
WSH_NBP_NAME* | Long | 4 |
WSH_NBP_NAME* | Long | 4 |
WCHAR* | Long | 4 |
CLSID* | Long | 4 |
FMTID* | Long | 4 |
GUID* | Long | 4 |
IID* | Long | 4 |
ACCESS_MASK | Long | 4 |
DWORD | Long | 4 |
short | Integer | 2 |
void* | Long | 4 |
void* | Long | 4 |
I_RPC_HANDLE | Long | 4 |
unsigned char* | Long | 4 |
I_RPC_HANDLE* | Long | 4 |
void* | Long | 4 |
unsigned long | Long | 4 |
void* | Long | 4 |
void* | Long | 4 |
long | Long | 4 |
unsigned long | Long | 4 |
HANDLE | Long | 4 |
LPVOID | Long | 4 |
char | Byte | 1 |
long | Long | 4 |
DWORD | Long | 4 |
double | Double | 8 |
long int | Long | 4 |
WORD | Integer | 2 |
DWORD | Long | 4 |
FARPROC | Long | 4 |
DWORD | Long | 4 |
float | Single | 4 |
short | Integer | 2 |
short | Integer | 2 |
short | Integer | 2 |
int | Long | 4 |
signed char | Byte | 1 |
int | Long | 4 |
long | Long | 4 |
short | Integer | 2 |
unsigned int | Long | 4 |
signed long | Long | 4 |
long | Long | 4 |
OLECHAR** | Long | 4 |
u_int | Long | 4 |
HANDLE* | Long | 4 |
__int64 | Double | 8 |
unsigned char | Byte | 1 |
unsigned char | Byte | 1 |
unsigned char | Byte | 1 |
double | Double | 8 |
double | Double | 8 |
void* | Long | 4 |
sqlHANDLE | Long | 4 |
sqlHANDLE | Long | 4 |
sqlHANDLE | Long | 4 |
sqlHANDLE | Long | 4 |
HWND | Long | 4 |
long | Long | 4 |
unsigned char | Byte | 1 |
void* | Long | 4 |
float | Single | 4 |
sqlSMALLINT | Integer | 2 |
char | Byte | 1 |
short | Integer | 2 |
sqlCHAR | Byte | 1 |
unsigned char | Byte | 1 |
unsigned char | Byte | 1 |
unsigned __int64 | Double | 8 |
unsigned long | Long | 4 |
unsigned short | Integer | 2 |
unsigned char | Byte | 1 |
wchar_t | Integer | 2 |
short | Integer | 2 |
long | Long | 4 |
long | Long | 4 |
DWORD | Long | 4 |
short int | Integer | 2 |
short int | Integer | 2 |
TCHAR | Byte/Integer | 1/2 |
TCHAR | Byte/Integer | 1/2 |
long | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
WORD | Integer | 2 |
unsigned char | Byte | 1 |
unsigned int | Long | 4 |
unsigned long | Long | 4 |
unsigned short | Integer | 2 |
unsigned char | Byte | 1 |
unsigned long int | Long | 4 |
unsigned long int | Long | 4 |
unsigned int | Long | 4 |
unsigned long | Long | 4 |
unsigned long | Long | 4 |
unsigned __int64 | Double | 8 |
unsigned char | Byte | 1 |
unsigned int | Long | 4 |
unsigned long | Long | 4 |
unsigned short | Integer | 2 |
BYTE_BLOB* | Long | 4 |
DWORD_BLOB* | Long | 4 |
FLAGGED_BYTE_BLOB* | Long | 4 |
FLAGGED_WORD_BLOB* | Long | 4 |
WORD_BLOB* | Long | 4 |
unsigned short | Integer | 2 |
unsigned short | Integer | 2 |
LONGLONG | Double | 8 |
unsigned short int | Integer | 2 |
unsigned short int | Integer | 2 |
char* | Long | 4 |
VARIANT | Variant | |
short | Integer | 2 |
VARIANT | Variant | |
unsigned short | Integer | 2 |
void* | Long | 4 |
wchar_t | Integer | 2 |
unsigned short | Integer | 2 |
wchar_t | Integer | 2 |
wchar_t | Integer | 2 |
LPVOID | Long | 4 |
FARPROC | Long | 4 |
FARPROC | Long | 4 |
wchar_t | Integer | 2 |
userSTGMEDIUM* | Long | 4 |
FLAGGED_WORD_BLOB* | Long | 4 |
userCLIPFORMAT* | Long | 4 |
userFLAG_STGMEDIUM* | Long | 4 |
RemotableHandle* | Long | 4 |
userHBITMAP* | Long | 4 |
RemotableHandle* | Long | 4 |
RemotableHandle* | Long | 4 |
userHENHMetaFILE* | Long | 4 |
RemotableHandle* | Long | 4 |
userHGLOBAL* | Long | 4 |
RemotableHandle* | Long | 4 |
RemotableHandle* | Long | 4 |
userHMetaFILE* | Long | 4 |
userHMetaFILEPICT* | Long | 4 |
userHPALETTE* | Long | 4 |
RemotableHandle* | Long | 4 |
RemSNB* | Long | 4 |
userSTGMEDIUM* | Long | 4 |
FARPROC | Long | 4 |
* | Long | 4 |
unsigned short | Integer | 2 |
UINT | Long | 4 |
DWORD | Long | 4 |
对于指针型的类型转入到Vb中应是ByRef的.其它的用ByVal,对于某些函数回调,需要用Addressof取函数地址,要注意的是要取地址的函数必需在模块文件中.否则会出错.
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/littlerain007/archive/2005/03/22/326569.aspx
原文链接:https://www.f2er.com/vb/261897.html