Data type conversions for API calls from Visual Basic
来源:互联网 发布:计算机视觉python 编辑:程序博客网 时间:2024/05/18 01:14
转贴自 http://www.codingdomain.com/visualbasic/win32api/datatypes/
Introduction
Visual Basic and the Windows API functions use different names for certain data types. This page provides a brief overview of those differences, and how to convert these types.
Summary of types
This is a list of the most common data types found in API declarations. Most of these names are aliases for standard integer types. In Visual Basic, you need to include the theByRef or ByVal keyword explicitly in the declaration. The aliases used in the orginal C-style declarations already have this set.
ByVal variable As LongOnly supply ByVal Nothing, ByVal 0& or vbNullString as valueVOIDSub procedureNot applicable; void means empty, nothing, nada, nope
Special notes
COLORREF
A COLORREF value is a red-green-blue combination. Visual Basic usesOLE_COLOR, which can also store system colors identifiers. TheCOLORREF type does not support this. To convert that type, use theoleTranslateColor(). API.
DWORD, WORD
Very often you can treat these types as Long values. ADWORD is also used to store two values; a LoWord and HiWord. The HiWord is stored in the first two bytes, and the LoWord is stored in the last two bytes of the long value.
Strings
Strings are automatically converted to their C-style equivalent. Pass them as ByVal variable As String. Functions like StrPtr() and StrConv() are very useful if you need to store the String in a structure.
Pointers
Pointers are special types which store the memory location of a variable. Visual Basic does not allow to use pointers directly, but usingByRef in the argument list has the desired effect. It will pass the memory location (pointer) of the variable to the function.
Function Pointers
A pointer to a function can be passed using the AddressOf operator. Most callback functions provide an additional parameter to include a custom long value (thelParam parameter). To pass an object-pointer to that value, useObjPtr(). In the callback function you can use the CopyMemory() API to copy the long value to an uninitialized object.
Unsigned types
Languages like C and C++ support so called "unsigned types". These types have a different range which Visual Basic does not support. A normalLong supports both negative and positive values. In an unsigned long, the negative range is not used.
This makes it posible to store larger positive values in the data type. For example, the value &HFFFFFFFF (-1 as Long) is 4294967295, which is twice as much a Visual BasicLong type can handle.
- Data type conversions for API calls from Visual Basic
- Basic Concepts for Learning from Data
- Windows API 函数 for Visual Basic
- 32 Bit - Windows API Calls for PowerBuilder
- Type Conversions in Cpp
- 下载地址Windows API函数for Visual Basic(win32 api) 中文版chm格试
- Visual Basic WinSock API模块
- Visual C++ Data Type Ranges
- 28 EBOOKS FOR VISUAL BASIC
- Visual Basic 2005 For Dummies
- Visual Basic for Application是什么
- Visual Basic不可能消失(From Yesky)
- Visual Basic .NET 代码示例 (From MS)
- No data type for node
- Effective C++ 19. type conversions
- FindFirstUrlCacheEntry Visual Basic 6 API函数
- Visual Basic Winsock API 函数详解
- go Type Identical &Value Assignability & Type Conversions
- 【iOS-Cocos2d游戏开发之八】开启高清(960*640)模式问题与解答、图片适配以及设置iphone横竖屏
- 复习Struts2之控制标签与数据标签
- java.sql.SQLException: 关闭的连接
- 创建Struts 配置文件 (struts-config.xml)
- Android库项目的导出及其引用资源
- Data type conversions for API calls from Visual Basic
- 谈一谈我对java单继承和多继承的理解。
- Iphone之UITableView
- 跨域的理解与实现
- 【iOS-Cocos2d游戏开发之九】讲解CCSpriteBatchNode与TP工具的".pvr.ccz",".plist"共用的终极精灵优化及注意事项!
- ARRAYLIST VECTOR LINKEDLIST 区别与用法
- android系统学习(1)-ubuntu 11.10环境搭建
- 解决农业银行k宝在win7下不能用的问题
- Web框架自身安全