guntopztm 发表于 2022-6-27 10:23:00

无法获得剪贴板数据长度

请教下各位高手,之前我在CAD2007,32位版本做了一个从剪贴板获得坐标,然后在CAD里导入变成对应坐标的圆的VBA程序,可等我把它移至64位的CAD2020版本后 原来代码中获得剪贴板数据长度lstrlen却总是返回0值,这里请教下是怎么回事 或者有什么其它方法吗?相关代码如下
Public Const CF_TEXT = 1
Public Declare PtrSafe Function GetClipboardData Lib "user32" (ByVal wFormat As Long) As Long
Public Declare PtrSafe Function CloseClipboard Lib "user32" () As Long
Public Declare PtrSafe Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Public Declare PtrSafe Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As Long) As Long
Public Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Long, ByVal ByteLen As Long)Public Sub location_clipboard()
      Dim hStrPtr   As Long, lLength       As Long, sBuffer       As String, str1() As String, str2() As String, Stext As String
      Dim nc As Integer
      CloseClipboard
      On Error Resume Next
      OpenClipboard 0&
      hStrPtr = GetClipboardData(CF_TEXT)
      lLength = lstrlen(hStrPtr) '就是这里 总是返回0 导致我无法赋值给其它变量
      If lLength > 0 Then
            sBuffer = Space$(lLength)
            CopyMemory ByVal sBuffer, ByVal hStrPtr, lLength
      end if   
End Sub

guntopztm 发表于 2022-6-27 16:17:00

ddddddddddddddd

guntopztm 发表于 2022-6-28 14:10:00

ddddddddddd

guntopztm 发表于 2022-6-30 14:56:00

ddddddddddd

guntopztm 发表于 2022-7-4 12:13:00

dddddddddddd
页: [1]
查看完整版本: 无法获得剪贴板数据长度