Description of pchar in the spms_api development interface developed on the. NET platform -- reprinted

Source: Internet
Author: User

Spinterface. dll

Upstream receiving function: getcngpdeliversm

Problem description: This development kit is developed for DELPHI6, which uses a data type that is not directly supported by VB and. Net such as pchar, which requires certain conversion.

The following is an example of VB. NET 2005 development code:

Definition:

Imports system. runtime. interopservices

Private declare function getcngpdeliversm lib "sp_interface.dll "(_
<Financialas (unmanagedtype. vbbyrefstr)> byref smsgid as string ,_
Byref bymsgformat as byte ,_
<Financialas (unmanagedtype. vbbyrefstr)> byref srecvtime as string ,_
<Financialas (unmanagedtype. vbbyrefstr)> byref sorgaddr as string ,_
<Financialas (unmanagedtype. vbbyrefstr)> byref sdestaddr as string ,_
Byref bymsglen as byte ,_
<Financialas (unmanagedtype. vbbyrefstr)> byref smsgcontent as string ,_
Byref byprovalue as byte ,_
Byref byisreport as byte ,_
<Financialas (unmanagedtype. vbbyrefstr)> byref ssrcmsgid as string ,_
<Financialas (unmanagedtype. vbbyrefstr)> byref ssubmitdate as string ,_
<Financialas (unmanagedtype. vbbyrefstr)> byref sdonedate as string ,_
<Financialas (unmanagedtype. vbbyrefstr)> byref sStatus as string ,_
Byref ideliverackresult as int32 ,_
<Financialas (unmanagedtype. vbbyrefstr)> byref link_id as string ,_
<Financialas (unmanagedtype. vbbyrefstr)> byref beneficiaryid as string) as int32

Early-Stage indicators

Public sub XX ()

Dim result as int32
Dim smsgid as new string (CHR (0), 10)
Dim bymsgformat as byte = 0
Dim srecvtime as new string (CHR (0), 14)
Dim sorgaddr as new string (CHR (0), 20)
Dim sdestaddr as new string (CHR (0), 20)
Dim bymsglen as byte = 0
Dim smsgcontent as new string (CHR (0), 254)
Dim byprovalue as byte = 0
Dim byisreport as byte = 0
Dim ssrcmsgid as new string (CHR (0), 20)
Dim ssubmitdate as new string (CHR (0), 10)
Dim sdonedate as new string (CHR (0), 10)
Dim sStatus as new string (CHR (0), 7)
Dim ideliverackresult as byte = 0
Dim link_id as new string (CHR (0), 20)
Dim beneficiaryid as new string (CHR (0), 21)

End sub

Detailed description:

Although the input parameters also have the pchar type in the downlink, the string type can be expressed and recognized by the system. We do not need to convert the data by ourselves, other types can be represented by the byte and int32 types in the development document.

Because pchar is a pointer reference in the uplink, such as byref or output, which is passed by reference, you need to host a pointer conversion from code to unmanaged code, so you can use unmanagedtype. vbbyrefstr performs "Features", indicating that the conversion is the same for C #, as if. net1.1 does not support this item, and I have never studied it.

In addition to this item, the memory space must be allocated. Here I use new string (CHR (0), 100) to indicate that the next 100 is the character length, which is the fixed length.

 

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.