none
vb api的大问题 RRS feed

  • 问题

  • '各位前辈,问题在语句的后面注释里面,帮忙看看。。
    Option
    Explicit

    Private Const CF_HDROP = 15

    Private Type POINT
      x As
    Long
      y As Long
    End Type

    Private Type DROPFILES
      pFiles As
    Long
      pt As POINT
      fNC As Long
      fWide As Long
    End
    Type

    Private Declare Function GlobalSize Lib "kernel32" _
    (ByVal hMem
    As Long) As Long
    Private Declare Function GlobalLock Lib "kernel32" _
    (ByVal hMem As Long) As Long
    Private Declare Function GlobalUnlock Lib
    "kernel32" _
    (ByVal hMem As Long) As Long

    Private Declare Function
    OpenClipboard Lib "user32" _
    (ByVal hwnd As Long) As Long
    Private Declare
    Function CloseClipboard Lib "user32" () As Long
    Private Declare Function
    GetClipboardData Lib "user32" _
    (ByVal wFormat As Long) As
    Long

    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory"
    _
    (Destination As Any, Source As Any, ByVal Length As Long)

    Private
    Sub ShowFilesOnClipboard()
      Dim lHandle As Long
    1 Dim lpResults As
    Long
    2 Dim lRet As Long
    3 Dim df As DROPFILES
    4 Dim strDest As
    String
    5 Dim lBufferSize As Long
    6 Dim arBuffer() As Byte
    7 Dim vNames
    As Variant
    8 Dim i As Long
       
    9 If OpenClipboard(0) Then
    10
    lHandle = GetClipboardData(CF_HDROP)
      ' If you don't find a CF_HDROP, you
    don't want to process anything
    11 If lHandle > 0 Then
    12 lpResults =
    GlobalLock(lHandle)
       
    13 lBufferSize = GlobalSize(lpResults)
    14
    ReDim arBuffer(0 To lBufferSize)
      '问题啊,下面为啥要用2个copymemory?第二个为啥用call? byval
    lpresults+df.pfiles啥意思?lbuffersize-len(df)代表啥意义?

    15 CopyMemory df,
    ByVal lpResults, Len(df)
    16 Call CopyMemory(arBuffer(0), ByVal lpResults +
    df.pFiles, _
      (lBufferSize - Len(df)))
       
    17 If df.fWide = 1
    Then
      ' it is wide chars--unicode
    18 strDest = arBuffer
    19 Else
    20
    strDest = StrConv(arBuffer, vbUnicode)
    21 End If
    22 GlobalUnlock
    lHandle

    '这里在做些啥事情啊?
    23 vNames =
    Split(strDest, vbNullChar)
    24 i = 0
    25 While Len(vNames(i)) > 0
    26
    List1.AddItem vNames(i)
    27 i = i + 1
    28 Wend
    29 End If
    30 End
    If
    31 CloseClipboard
    End Sub

    Private Sub Command1_Click()
    1 Call
    ShowFilesOnClipboard
    End Sub


    Private Sub showMewnd_Click()
    1
    Text1.Text = Me.hwnd
    2 Text2.Text = Null
       
    End Sub

    红尘多可笑,痴情最无聊,目空一切也好

    • 已移动 Youen Zen 2012年4月16日 6:14 VB6 issue (发件人:Visual Basic)
    2012年4月13日 11:13

全部回复

  • 您好,

    本版块主要讨论VB.NET相关主题,而本主题是与VB6相关,所以我将此主题移动到一般性问题讨论区。 感谢您的理解与支持!

    Best regards,


    Shanks Zen
    MSDN Community Support | Feedback to us

    2012年4月16日 6:13