接口函数 char **_GetAddress(char *IP)char **p=_GetAddress(char *IP)那么*P指向省市,*(P+1)指向详细,*(P+2)指向提供者在VB中如何声明呢?

解决方案 »

  1.   

    能说的清楚一些吗?
    上面的函数返回值是双指针类型的耶~
    我们该怎么或者返回的3个值呢?不能用单一的byref了吧。
      

  2.   

    'char **_GetAddress(char *IP)
    private declare function GetAddress lib "" alias "_GetAddress" (byval IP as string) as longPrivate Declare Function lstrlenA Lib "kernel32" (ByVal lpString As Long) As Long
    Private Declare Function lstrlenW Lib "kernel32" (ByVal lpString As Long) As LongPrivate Declare Function lstrcpyA Lib "kernel32" (ByVal lpString1 As Long, ByVal lpString2 As Long) As Long
    Private Declare Function lstrcpyW Lib "kernel32" (ByVal lpString1 As Long, ByVal lpString2 As Long) As Longprivate sub form_load
    dim p as long 
    dim u as long
    u=lenb(p)'一个单位长度
    p=GetAddress ("210.33.88.1")
    '*P指向省市,*(P+1)指向详细,*(P+2)指向提供者
    dim 省市 as string,详细 as string,提供者 as string
    省市=strfromptr(p)
    详细=strfromptr(p+1*u)
    提供者=strfromptr(p+2*u)
    '...
    end subPublic Function StrFromPtr(ByVal lpString As Long, Optional fUnicode As Boolean = False) As String
        On Error Resume Next
        If fUnicode Then
            StrFromPtr = String(lstrlenW(lpString), Chr(0))
            lstrcpyW StrPtr(StrFromPtr), ByVal lpString
        Else
            StrFromPtr = String(lstrlenA(lpString), Chr(0))
            lstrcpyA ByVal StrFromPtr, ByVal lpString
        End If
    End Function