自已做的AsniStr类
最近在学Delphi,感叹它的框架,而VB6没有自已框架。
从中获得了一些灵感。自已做了一个clsAnsiStr类。
'---ClsAnsStr---Strart
Private Declare Function lstrlenStr Lib "kernel32" Alias
"lstrlenA" (ByVal lpString As String) As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA"
(ByVal lpString As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias
"RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As
Long)
Private Declare Sub CopyMemorySrcStr Lib "kernel32" Alias
"RtlMoveMemory" (Destination As Any, ByVal Source As String, ByVal
Length As Long)
Private Declare Sub CopyMemoryDstStr Lib "kernel32" Alias
"RtlMoveMemory" (ByVal Destination As String, Source As Any, ByVal
Length As Long)
Private b() As Byte
Private FLength As Long
Private Sub Class_Initialize()
End Sub
Public Property Get Ptr() As Long
End Property
Public Function FromVBStr(s As String)
End Function
Public Property Get Length() As Long
End Property
Public Property Let Length(ByVal vNewValue As Long)
End Property
Public Function ToVBStr() As String
End Function
'--------clsAnsiStrEnd---
这样,VB在调用api有字符串指针时就方便多了(申明时全可以改成byval lpStr as long 了,免得调用时出错) 。如下。
Private Declare Function GetSystemDirectory Lib "kernel32" Alias
"GetSystemDirectoryA" (ByVal lpBuffer As
Long, ByVal nSize As Long) As Long
Private Sub Command1_Click()
End Sub
Private Sub Form_Load()
End Sub
最后,我由此类想到很多关于指针的应用。
浙公网安备 33010602011771号