
My previously posted GetClipboard returned a 1023 byte string that was padded with a thousand vbNullChar characters.

My clipboard contained "Dim MyWeirdVariable" which I copied from an Excel vba program. Option Explicit Private Declare Function OpenClipboard Lib "user32.dll" (ByVal hwnd As Long) As Long Private Declare Function Empt圜lipboard Lib "user32.dll" () As Long Private Declare Function CloseClipboard Lib "user32.dll" () As Long Private Declare Function IsClipboardFormatAvailable Lib "user32.dll" (ByVal wFormat As Long) As Long Private Declare Function GetClipboardData Lib "user32.dll" (ByVal wFormat As Long) As Long Private Declare Function SetClipboardData Lib "user32.dll" (ByVal wFormat As Long, ByVal hMem As Long) As Long Private Declare Function GlobalAlloc Lib "kernel32.dll" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long Private Declare Function GlobalLock Lib "kernel32.dll" (ByVal hMem As Long) As Long Private Declare Function GlobalUnlock Lib "kernel32.dll" (ByVal hMem As Long) As Long Private Declare Function GlobalSize Lib "kernel32" (ByVal hMem As Long) As Long Private Declare Function lstrcpy Lib "kernel32.dll" Alias "lstrcpyW" (ByVal lpString1 As Long, ByVal lpString2 As Long) As Long Public Sub SetClipboard(ByVal sUniText As String) Dim i As Long Dim iStrPtr As Long Dim iLen As Long Dim iLock As Long Const GMEM_MOVEABLE As Long = &H2 Const GMEM_ZEROINIT As Long = &H40 Const CF_UNICODETEXT As Long = &HD OpenClipboard 0& Empt圜lipboard iLen = LenB(sUniText) + 2& iStrPtr = GlobalAlloc(GMEM_MOVEABLE Or GMEM_ZEROINIT, iLen) iLock = GlobalLock(iStrPtr) lstrcpy iLock, StrPtr(sUniText) GlobalUnlock iStrPtr SetClipboardData CF_UNICODETEXT, iStrPtr CloseClipboard End Sub Public Function GetClipboard() As String Dim iStrPtr As Long Dim iLen As Long Dim iLock As Long Dim sUniText As String Const CF_UNICODETEXT As Long = 13& OpenClipboard 0& If IsClipboardFormatAvailable(CF_UNICODETEXT) Then iStrPtr = GetClipboardData(CF_UNICODETEXT) If iStrPtr Then iLock = GlobalLock(iStrPtr) iLen = GlobalSize(iStrPtr) sUniText = String$(iLen \ 2& - 1&, vbNullChar) lstrcpy StrPtr(sUniText), iLock GlobalUnlock iStrPtr End If GetClipboard = sUniText End If CloseClipboard End Function Here are the ones I use, but there are lots of alternatives on the web. I have converted all my programs to use APIs. In either case, I no longer recommend rebuilding a profile: the only reliable solution I have found is to stop using DataObjects. Profile corruption might be the cause of the problem, but the corruption re-occurs fairly quickly after rebuilding the profile. Profile corruption is not the cause of the problem.Ģ.

The data objects problem still occurs randomly. Plus, the computer is now attached to a Windows Server 2016 domain controller instead of the old SBS 2003.
#1clipboard crash windows 10 windows 10
I have scrapped my old lenovo computer and now have a much more powerful computer that came with windows 10 pre installed. Test.GetFromClipboard ' sometimes, when corruption occurs, debugger stops even when there is no errorĪ lot has happened since I posted this problem long ago. Set test = CreateObject("New: ") ' late binding to dataobjectĪpplication.Wait (Now + TimeValue("00:00:02")) I am going to reboot and see if things change. It appears that when any explorer window is related to a physical disk drive, dataobjects fail.īu dataobjects workt if all explorer windows are displaying a "simulated folder" which is entirely in the registry.

#1clipboard crash windows 10 Pc
If windows explorer is closed dataobjects work perfectly.ĭataobject fail if I have opened these 3 explorer windows: 1) This Pc 2) Quick access 3) desktopĭataobjects work if I only have these open 1) This Pc 2) Quick access If any Explorer window is displaying any folder on C: or D: or E then databobjects do not work. I finally have something that is repeatable.
