打印本文 打印本文 关闭窗口 关闭窗口
有关API字符串--API programmer请看之二
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2948  更新时间:2009/4/23 18:58:16  文章录入:mintao  责任编辑:mintao
CopyMemory ByVal StrPtr(LPWSTRtoBSTR), ByVal lpwsz, cChars * 2

   

End Function

 

从LPSTR到BSTR

将上面的小函数做一个小小的修改,我们就可以得到一个将LPSTR转换为BSTR的函数。(注意Trim函数的功能是去除前导空白和尾随空白)

 

Function LPSTRtoBSTR(ByVal lpsz As Long) As String

   

'''' Input: a valid LPSTR pointer lpsz

'''' Output: a sBSTR with the same character array

   

Dim cChars As Long

   

'''' Get number of characters in lpsz

cChars = lstrlenA(lpsz)

   

'''' Initialize string

LPSTRtoBSTR = String$(cChars, 0)

   

'''' Copy string

CopyMemory ByVal StrPtr(LPSTRtoBSTR), ByVal lpsz, cChars

   

'''' Convert to Unicode

LPSTRtoBSTR = Trim0(StrConv(LPSTRtoBSTR, vbUnicode))

   

End Function

 

 

 

 

 

 

上一页  [1] [2] [3] [4] [5] 

打印本文 打印本文 关闭窗口 关闭窗口