Index: /trunk/include/VBox/com/string.h
===================================================================
--- /trunk/include/VBox/com/string.h	(revision 85287)
+++ /trunk/include/VBox/com/string.h	(revision 85288)
@@ -173,4 +173,28 @@
     }
 
+    /**
+     * Extended assignment method that returns a COM status code instead of an
+     * exception on failure.
+     *
+     * @returns S_OK or E_OUTOFMEMORY.
+     * @param   a_rSrcStr   The source string
+     */
+    HRESULT assignEx(const Bstr &a_rSrcStr) RT_NOEXCEPT
+    {
+        return cleanupAndCopyFromEx((const OLECHAR *)a_rSrcStr.m_bstr);
+    }
+
+    /**
+     * Extended assignment method that returns a COM status code instead of an
+     * exception on failure.
+     *
+     * @returns S_OK or E_OUTOFMEMORY.
+     * @param   a_pSrcStr   The source string
+     */
+    HRESULT assignEx(CBSTR a_pSrcStr) RT_NOEXCEPT
+    {
+        return cleanupAndCopyFromEx((const OLECHAR *)a_pSrcStr);
+    }
+
 #ifdef _MSC_VER
 # if _MSC_VER >= 1400
@@ -950,4 +974,18 @@
     /** cleanup() + copyFrom() - for assignment operators.  */
     void cleanupAndCopyFrom(const OLECHAR *a_bstrSrc);
+
+    /**
+     * Protected internal helper to copy a string, implying cleanup().
+     *
+     * This variant copies from a zero-terminated UTF-16 string (which need not be a
+     * BSTR, i.e. need not have a length prefix).
+     *
+     * If the source is empty, this sets the member string to NULL.
+     *
+     * @param   a_bstrSrc           The source string.  The caller guarantees
+     *                              that this is valid UTF-16.
+     * @returns S_OK or E_OUTOFMEMORY
+     */
+    HRESULT cleanupAndCopyFromEx(const OLECHAR *a_bstrSrc) RT_NOEXCEPT;
 
     /**
Index: /trunk/src/VBox/Main/glue/string.cpp
===================================================================
--- /trunk/src/VBox/Main/glue/string.cpp	(revision 85287)
+++ /trunk/src/VBox/Main/glue/string.cpp	(revision 85288)
@@ -620,5 +620,7 @@
     {
         m_bstr = ::SysAllocString(a_bstrSrc);
-        if (!m_bstr)
+        if (RT_LIKELY(m_bstr))
+        { /* likely */ }
+        else
             throw std::bad_alloc();
     }
@@ -632,4 +634,22 @@
     cleanup();
     copyFrom(a_bstrSrc);
+}
+
+
+HRESULT Bstr::cleanupAndCopyFromEx(const OLECHAR *a_bstrSrc) RT_NOEXCEPT
+{
+    cleanup();
+
+    if (a_bstrSrc && *a_bstrSrc)
+    {
+        m_bstr = ::SysAllocString(a_bstrSrc);
+        if (RT_LIKELY(m_bstr))
+        { /* likely */ }
+        else
+            return E_OUTOFMEMORY;
+    }
+    else
+        m_bstr = NULL;
+    return S_OK;
 }
 
