API declaration in VB

Source: Internet
Author: User

1. For a string, if it is an lpctstr string, use byval! Otherwise, it may only be cstring. This type of VB cannot be processed! In addition, there is no string type in VC.

2. For the type [in] defined by the VB system, if the API is a pointer, is it used?For example, istream *Stream,ByvalStream as iunknown
3. For the type defined by the VB system, such as stream \ image [in], ifNot a pointer,

4. For a type not defined in VB system [in], if the API is a pointer, useByref, SuchLprect Lprect is defined Byref Lprect as rectOr byval varptr (rect) as long
5. For a type not defined in VB system [in], ifNot a pointerTo ensure that the actual length of the two parameters in the VB statement is the same (the number is not required to be the same, because reference is required for custom data types), for example:
Bool ptinrect (constRect * LPRC, Point pt)
Declare function ptinrect lib "USER32" (lprect as rect, byval X as long, byval y as long) as long
You can also:
Declare function ptinrect lib "USER32 "(Lprect as rect, Byval X as long, byval y as long) as long
Declare function ptinrect lib "USER32 "(Byval LPRC as long,Byval X as long, byval y as long) as long
Declare function ptinrect lib "USER32" (lprect as rect, byval cur as currency) as long
Declare function ptinrect lib "USER32" (byval LPRC as long, byval cur as currency) as long
Declare function ptinrect lib "USER32" (byval cur as currency, byval X as long) as long
6. For the returned pointer, no matter which type is long,What if other struct types are returned??

7.If the value returned in the parameter is not set to byvalIf the returned pointer \ Double pointer \ handle [out], all are defined as byref *** as long,
The following types are not defined in the VB system:You can use public type---- -- end type to define it! If it is a class in C ++, there is nothing in VB.
Obtained by groupClass type,It can be used as a custom data type in the VB system!
Gdiploadimagefromstreamicm (istream * stream, gpimage ** image );//Assume that both of these are [in] parameters.!

Public declare function gdiploadimagefromstream lib "gdiplus" (byval stream as long, image as long) as gpstatus
Image is the value of the gpimage * type pointer, pointing to gpimage. Stream is a pointer to an istream object.
Public declare function gdiploadimagefromstream lib "gdiplus" (byref stream as istream, byval image as long) as gpstatus
Image is the value of the gpimage ** type pointer, pointing to gpimage *. Stream is an istream object.

Public declare function gdiploadimagefromstream lib "gdiplus" (byref stream as istream, image as gpimage *) as gpstatus' is actually impossible, just to explain the truth
The image is of the gpimage * type. After byref, it becomes of the gpimage ** type.
Public declare function gdiploadimagefromstream lib "gdiplus" (byref stream as istream, byval image as gpimage **) as gpstatus' is actually impossible, but it is used to explain the truth
Image is of the gpimage ** type. Because the type is correct, it must be byval!

Pointer, You can first obtain the byval implicit transfer, or directly use the byref variable to explicitly pass, but the two are passed to the APIContent pointed to by pointerAll types are what the API wants.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.