Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp	(revision 60771)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp	(revision 60772)
@@ -95,4 +95,34 @@
 }
 
+
+static int vboxOpenClipboard(HWND hwnd)
+{
+    /* "OpenClipboard fails if another window has the clipboard open."
+    * So try a few times and wait up to 1 second.
+    */
+    int rc;
+
+    uint32_t u32SleepMS = 1;
+    int i;
+    for (i = 0; i <= 9; ++i) /* u32SleepMS = [1..512] */
+    {
+        if (OpenClipboard(hwnd))
+        {
+            rc = 0;
+            break;
+        }
+        rc = RTErrConvertFromWin32(GetLastError());
+        
+        RTThreadSleep(u32SleepMS);
+        u32SleepMS <<= 1;
+    }
+#ifdef LOG_ENABLED
+    if (i > 0)
+        LogFlow(("vboxOpenClipboard: %d times tried to open clipboard. \n", ++i));
+#endif
+    return rc;
+}
+
+
 static int vboxClipboardChanged(PVBOXCLIPBOARDCONTEXT pCtx)
 {
@@ -100,10 +130,6 @@
 
     /* Query list of available formats and report to host. */
-    int rc = VINF_SUCCESS;
-    if (FALSE == OpenClipboard(pCtx->hwnd))
-    {
-        rc = RTErrConvertFromWin32(GetLastError());
-    }
-    else
+    int rc = vboxOpenClipboard(pCtx->hwnd);
+    if(RT_SUCCESS(rc))
     {
         uint32_t u32Formats = 0;
@@ -147,4 +173,8 @@
         CloseClipboard();
         rc = VbglR3ClipboardReportFormats(pCtx->u32ClientID, u32Formats);
+    }
+    else
+    {
+        LogFlow(("vboxClipboardChanged: error in open clipboard. hwnd: %x. err: %Rrc\n", pCtx->hwnd, rc));
     }
     return rc;
@@ -472,9 +502,14 @@
              * windows is to be destroyed and therefore the guest side becomes inactive.
              */
-            if (OpenClipboard(hwnd))
+            int res = vboxOpenClipboard(hwnd);
+            if (RT_SUCCESS(res))
             {
                 EmptyClipboard();
                 CloseClipboard();
             }
+            else
+            {
+                LogFlowFunc(("WM_RENDERALLFORMATS: Failed to open clipboard! rc: %Rrc\n", res));
+            }
         } break;
 
@@ -483,10 +518,7 @@
             /* Announce available formats. Do not insert data, they will be inserted in WM_RENDER*. */
             uint32_t u32Formats = (uint32_t)lParam;
-
-            if (FALSE == OpenClipboard(hwnd))
-            {
-                LogFlowFunc(("WM_USER: Failed to open clipboard! Last error = %ld\n", GetLastError()));
-            }
-            else
+            
+            int res = vboxOpenClipboard(hwnd);
+            if(RT_SUCCESS(res))
             {
                 EmptyClipboard();
@@ -519,4 +551,8 @@
                 LogFlowFunc(("WM_USER: hClip = %p, err = %ld\n", hClip, GetLastError ()));
             }
+            else
+            {
+                LogFlowFunc(("WM_USER: Failed to open clipboard! error = %Rrc\n", res));
+            }
         } break;
 
@@ -527,9 +563,6 @@
             HANDLE hClip = NULL;
 
-            if (FALSE == OpenClipboard(hwnd))
-            {
-                LogFlowFunc(("WM_USER: Failed to open clipboard! Last error = %ld\n", GetLastError()));
-            }
-            else
+            int res = vboxOpenClipboard(hwnd);
+            if (RT_SUCCESS(res))
             {
                 int vboxrc;
@@ -602,4 +635,8 @@
                 CloseClipboard();
             }
+            else
+            {
+                LogFlowFunc(("WM_USER: Failed to open clipboard! rc: %Rrc\n", res));
+            }
 
             if (hClip == NULL)
Index: /trunk/src/VBox/HostServices/SharedClipboard/VBoxClipboard-win.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/VBoxClipboard-win.cpp	(revision 60771)
+++ /trunk/src/VBox/HostServices/SharedClipboard/VBoxClipboard-win.cpp	(revision 60772)
@@ -111,4 +111,5 @@
 #endif /* LOG_ENABLED */
 
+
 static void vboxClipboardInitNewAPI(VBOXCLIPBOARDCONTEXT *pCtx)
 {
@@ -143,4 +144,34 @@
 }
 
+
+static int vboxOpenClipboard(HWND hwnd)
+{
+    /* "OpenClipboard fails if another window has the clipboard open."
+    * So try a few times and wait up to 1 second.
+    */
+    int rc;
+
+    uint32_t u32SleepMS = 1;
+    int i;
+    for (i = 0; i <= 9; ++i) /* u32SleepMS = [1..512] */
+    {
+        if (OpenClipboard(hwnd))
+        {
+            rc = 0;
+            break;
+        }
+        rc = RTErrConvertFromWin32(GetLastError());
+
+        RTThreadSleep(u32SleepMS);
+        u32SleepMS <<= 1;
+    }
+#ifdef LOG_ENABLED
+    if (i > 0)
+        LogFlow(("vboxOpenClipboard: %d times tried to open clipboard. \n", ++i));
+#endif
+    return rc;
+}
+
+
 static void vboxClipboardGetData (uint32_t u32Format, const void *pvSrc, uint32_t cbSrc,
                                   void *pvDst, uint32_t cbDst, uint32_t *pcbActualDst)
@@ -194,5 +225,6 @@
 
     /* Query list of available formats and report to host. */
-    if (OpenClipboard (pCtx->hwnd))
+    int rc = vboxOpenClipboard(pCtx->hwnd);
+    if (RT_SUCCESS(rc))
     {
         uint32_t u32Formats = 0;
@@ -240,4 +272,8 @@
         vboxSvcClipboardReportMsg (pCtx->pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS, u32Formats);
     }
+    else
+    {
+        LogFlow(("vboxClipboardChanged: error in open clipboard. hwnd: %x. err: %Rrc\n", pCtx->hwnd, rc));
+    }
 }
 
@@ -491,9 +527,14 @@
              * windows is to be destroyed and therefore the guest side becomes inactive.
              */
-            if (OpenClipboard (hwnd))
+            int res = vboxOpenClipboard(hwnd);
+            if (RT_SUCCESS(res))
             {
                 EmptyClipboard();
 
                 CloseClipboard();
+            }
+            else
+            {
+                LogFlow(("vboxClipboardWndProc: WM_RENDERALLFORMATS: error in open clipboard. hwnd: %x, rc: %Rrc\n", hwnd, res));
             }
         } break;
@@ -515,5 +556,6 @@
             Log(("WM_USER u32Formats = %02X\n", u32Formats));
 
-            if (OpenClipboard (hwnd))
+            int res = vboxOpenClipboard(hwnd);
+            if (RT_SUCCESS(res))
             {
                 EmptyClipboard();
@@ -553,5 +595,5 @@
             else
             {
-                dprintf(("window proc WM_USER: failed to open clipboard\n"));
+                dprintf(("window proc WM_USER: failed to open clipboard. rc: %Rrc \n", res));
             }
         } break;
@@ -748,5 +790,6 @@
      * The guest wants to read data in the given format.
      */
-    if (OpenClipboard (pClient->pCtx->hwnd))
+    int rc = vboxOpenClipboard(pClient->pCtx->hwnd);
+    if (RT_SUCCESS(rc))
     {
         dprintf(("Clipboard opened.\n"));
@@ -831,5 +874,5 @@
     else
     {
-        dprintf(("failed to open clipboard\n"));
+        dprintf(("vboxClipboardReadData: failed to open clipboard, rc: %Rrc \n", rc));
     }
 
