Name 'VarPtr' is not declared.In old vb code

后端 未结 2 1515
孤城傲影
孤城傲影 2021-01-23 04:49

I have a old code in VB.Now I convert it into vb.net.There is a line in a code

Dim pCParameters As Integer

pCParameters = VarPtr(Parameters)

2条回答
  •  忘掉有多难
    2021-01-23 05:18

    Yes I found the answer.The new VarPtr function is

    Public Function VarPtr(ByVal e As Object) As Integer
    Dim GC As GCHandle = GCHandle.Alloc(e, GCHandleType.Pinned)
    Dim GC2 As Integer = GC.AddrOfPinnedObject.ToInt32
    GC.Free()
    Return GC2
    

提交回复
热议问题