http://ygyuan.go.163.com/
http://ygyuan.3322.net/API 超级工具下载!

解决方案 »

  1.   

    Declare Sub CopyMemory Lib "KERNEL32"  Alias "RtlMoveMemory" ( _
       lpvDest As Any,  lpvSource As Any, ByVal cbCopy as Long)
        这个函数可以将 lpvDest的momory copy 到lpvSource上去,cbCopy则代表要copy多少个byte。例如想一个Double值存在Memory中的各个byte到底是多少。Dim  dbl  as  Double
    Dim  bte(0 to 7) as Byte
    Dbl = 168.256
    CopyMemory dbl,  byt(0),  8
      

  2.   

    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
    Private Declare Function GetTickCount Lib "kernel32" () As Long
    Private Sub Form_Load()
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Dim sSave As String, Cnt As Long, T As Long, Pos As Long, Length As Long
        Const mStr = "Hello "
        Length = Len(mStr)
        sSave = Space(5000 * Length) 'make buffer for justified comparison
        'Get the current tickcount
        T = GetTickCount
        Pos = 1
        sSave = Space(5000 * Length)
        For Cnt = 1 To 5000
          Mid(sSave, Pos, Length) = mStr
          Pos = Pos + Length
        Next Cnt
        'Show the results
        MsgBox "It took Visual basic" + Str$(GetTickCount - T) + " msecs. to add 5000 times a string to itself."
        'Get the current tickcount
        T = GetTickCount
        Pos = 0
        sSave = Space(5000 * Length)
        For Cnt = 1 To 5000
            CopyMemory ByVal StrPtr(sSave) + Pos, ByVal StrPtr(mStr), LenB(mStr)
            Pos = Pos + LenB(mStr)
        Next Cnt
        'Show the results
        MsgBox "It took CopyMemory" + Str$(GetTickCount - T) + " msecs. to add 5000 times a string to itself."
    End Sub
      

  3.   

    Public Declare Sub CopyMemory _
       Lib "kernel32" Alias "RtlMoveMemory" _
          (pDest As Any, _
          pSrc As Any, _
          ByVal ByteLen As Long)Public Declare Function SetWindowLong _
       Lib "user32" Alias "SetWindowLongA" _
          (ByVal hWnd As Long, _
          ByVal nIndex As Long, _
          ByVal dwNewLong As Long) As LongPublic Declare Function GetWindowLong _
       Lib "user32" Alias "GetWindowLongA" _
          (ByVal hWnd As Long, _
          ByVal nIndex As Long) As LongPublic Declare Function CallWindowProc _
       Lib "user32" Alias "CallWindowProcA" _
          (ByVal lpPrevWndFunc As Long, _
          ByVal hWnd As Long, _
          ByVal Msg As Long, _
          ByVal wParam As Long, _
          ByVal lParam As Long) As Long
    Public Const GWL_WNDPROC = (-4)
    Public Const GWL_USERDATA = (-21)Dim ctlShadowControl As TextEx
    Dim ptrObject As LongPublic Function SubWndProc( _
       ByVal hWnd As Long, _
       ByVal Msg As Long, _
       ByVal wParam As Long, _
       ByVal lParam As Long) As Long   On Error Resume Next   ptrObject = GetWindowLong(hWnd, GWL_USERDATA)
       CopyMemory ctlShadowControl, ptrObject, 4
       SubWndProc = ctlShadowControl.WindowProc(hWnd, Msg, wParam, lParam)
       CopyMemory ctlShadowControl, 0&, 4
       Set ctlShadowControl = Nothing
    End Function
      

  4.   

    不是说CopyMemory比较快吗?怎么lihonggen0(李洪根,用VB,标准答案来了) 的例子中反而慢了。
      

  5.   

    在VB里多用一次API回调的Compare、多用一次CopyMemory都是很大的开销