C # reference the DLL written in VB

Source: Internet
Author: User

Private declare sub make lib "makebar. dll "_
(Ucdata as byte, byval nlen as long, byval szfilename as string, byval nclumn as long, byval nerr as long, byval nhlratio as long)

Dim A () as byte
A = strconv (text1.text, vbfromunicode)
Make a (0), ubound (a)-lbound (A) + 1, "abc.bmp", clng (text2.text), clng (text3.text), clng (text4.text)

C #
[Dllimport ("makebar. dll", entrypoint = "make")]
Private Static extern void make (ref byte ucdata, long nlen, string szfilename, long nclumn, long nerr, long nhlratio );

Byte [] A = system. Text. encoding. utf8.getbytes (text1.text );

Make (Ref A [0], A. length, "abc.bmp", long. parse (text2.text), long. parse (text3.text), long. parse (text4.text );

I am not very sure about the ref parameter. In the old VB, if byval is not written, it is byref, but it seems that in C #, ref can only pass simple variables, such as A, and "A [0]" cannot be passed by Ref. If a [0] does not need to be changed after the process, remove the two ref.

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.