等效于StrPtr [英] Equivalent of StrPtr
本文介绍了等效于StrPtr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
但是我无法将VB-6.0的StrPtr函数转换为VB.Net或C#..
我该如何解决呢??
请提供正确的代码..
But i can''t convert StrPtr Function of VB-6.0 to VB.Net Or C#..
How can i solve this???
Please supply to right code..
推荐答案
检查以下链接
VB.NET中的StrPtr等效
Check the following link
StrPtr Equivalent in VB.NET
确保已安装msvbvm60.dll并尝试使用此方法
insure msvbvm60.dll is installed and Try This
Private Declare Function VarPtr Lib "msvbvm60.dll" Alias "VarPtr" (ByVal lpObject As String) As Integer
Function StrPtr(ByVal x As String) As Integer
Return VarPtr(x)
End Function
或参见:
http://www.codeproject.com/KB/vb/Marshal.aspx
它解释如下代码:
Or see:
http://www.codeproject.com/KB/vb/Marshal.aspx
it explain code like:
' dim managed variable
Dim MyString As String = "Adnan Samuel"
' pin variable and create
' GC handle instance
Dim gh As GCHandle = GCHandle.Alloc (MyString, GCHandleType.Pinned)
' get address of variable
Dim AddrOfMyString As IntPtr = gh.AddrOfPinnedObject()
Console.WriteLine (AddrOfMyString.ToString())
' free the handle and unpin variable
gh.Free()
这篇关于等效于StrPtr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文