Index: /trunk/src/VBox/Main/include/VirtualBoxBase.h
===================================================================
--- /trunk/src/VBox/Main/include/VirtualBoxBase.h	(revision 55581)
+++ /trunk/src/VBox/Main/include/VirtualBoxBase.h	(revision 55582)
@@ -758,5 +758,6 @@
                                     Utf8Str aText,
                                     bool aWarning,
-                                    bool aLogIt);
+                                    bool aLogIt,
+                                    LONG aResultDetail = 0);
     static void clearError(void);
 
@@ -764,4 +765,8 @@
     HRESULT setError(HRESULT aResultCode, const char *pcsz, ...);
     HRESULT setError(const ErrorInfo &ei);
+    HRESULT setErrorVrc(int vrc);
+    HRESULT setErrorVrc(int vrc, const char *pcszMsgFmt, ...);
+    HRESULT setErrorBoth(HRESULT hrc, int vrc);
+    HRESULT setErrorBoth(HRESULT hrc, int vrc, const char *pcszMsgFmt, ...);
     HRESULT setWarning(HRESULT aResultCode, const char *pcsz, ...);
     HRESULT setErrorNoLog(HRESULT aResultCode, const char *pcsz, ...);
Index: /trunk/src/VBox/Main/src-all/VirtualBoxBase.cpp
===================================================================
--- /trunk/src/VBox/Main/src-all/VirtualBoxBase.cpp	(revision 55581)
+++ /trunk/src/VBox/Main/src-all/VirtualBoxBase.cpp	(revision 55582)
@@ -37,4 +37,5 @@
 #include "VirtualBoxErrorInfoImpl.h"
 #include "Logging.h"
+#include "Global.h"
 
 #include "VBox/com/ErrorInfo.h"
@@ -168,5 +169,6 @@
                                          Utf8Str aText,
                                          bool aWarning,
-                                         bool aLogIt)
+                                         bool aLogIt,
+                                         LONG aResultDetail /* = 0*/)
 {
     /* whether multi-error mode is turned on */
@@ -174,5 +176,5 @@
 
     if (aLogIt)
-        LogRel(("%s [COM]: aRC=%Rhrc (%#08x) aIID={%RTuuid} aComponent={%s} aText={%s}, preserve=%RTbool\n",
+        LogRel(("%s [COM]: aRC=%Rhrc (%#08x) aIID={%RTuuid} aComponent={%s} aText={%s}, preserve=%RTbool aResultDetail=%d\n",
                 aWarning ? "WARNING" : "ERROR",
                 aResultCode,
@@ -182,5 +184,6 @@
                 aText.c_str(),
                 aWarning,
-                preserve));
+                preserve,
+                aResultDetail));
 
     /* these are mandatory, others -- not */
@@ -259,5 +262,5 @@
 
         /* set the current error info and preserve the previous one if any */
-        rc = info->init(aResultCode, aIID, pcszComponent, aText, curInfo);
+        rc = info->initEx(aResultCode, aResultDetail, aIID, pcszComponent, aText, curInfo);
         if (FAILED(rc)) break;
 
@@ -303,5 +306,5 @@
 
             /* set the current error info and preserve the previous one if any */
-            rc = info->init(aResultCode, aIID, pcszComponent, Bstr(aText), curInfo);
+            rc = info->initEx(aResultCode, aResultDetail, aIID, pcszComponent, Bstr(aText), curInfo);
             if (FAILED(rc)) break;
 
@@ -504,4 +507,103 @@
 
 /**
+ * Converts the VBox status code a COM one and sets the error info.
+ *
+ * The VBox status code is made available to the API user via
+ * IVirtualBoxErrorInfo::resultDetail attribute.
+ *
+ * @param   vrc             The VBox status code.
+ * @return  COM status code appropriate for @a vrc.
+ *
+ * @sa      VirtualBoxBase::setError(HRESULT)
+ */
+HRESULT VirtualBoxBase::setErrorVrc(int vrc)
+{
+    return setErrorInternal(Global::vboxStatusCodeToCOM(vrc),
+                            this->getClassIID(),
+                            this->getComponentName(),
+                            Utf8Str("%Rrc", vrc),
+                            false /* aWarning */,
+                            true /* aLogIt */,
+                            vrc /* aResultDetail */);
+}
+
+/**
+ * Converts the VBox status code a COM one and sets the error info.
+ *
+ * @param   vrc             The VBox status code.
+ * @param   pcszMsgFmt      Error message format string.
+ * @param   ...             Argument specified in the @a pcszMsgFmt
+ * @return  COM status code appropriate for @a vrc.
+ *
+ * @sa      VirtualBoxBase::setError(HRESULT, const char *, ...)
+ */
+HRESULT VirtualBoxBase::setErrorVrc(int vrc, const char *pcszMsgFmt, ...)
+{
+    va_list va;
+    va_start(va, pcszMsgFmt);
+    HRESULT hrc = setErrorInternal(Global::vboxStatusCodeToCOM(vrc),
+                                   this->getClassIID(),
+                                   this->getComponentName(),
+                                   Utf8Str(pcszMsgFmt, va),
+                                   false /* aWarning */,
+                                   true /* aLogIt */,
+                                   vrc /* aResultDetail */);
+    va_end(va);
+    return hrc;
+}
+
+/**
+ * Sets error info with both a COM status and an VBox status code.
+ *
+ * The VBox status code is made available to the API user via
+ * IVirtualBoxErrorInfo::resultDetail attribute.
+ *
+ * @param   hrc             The COM status code to return.
+ * @param   vrc             The VBox status code.
+ * @return  Most likely @hrc, see setErrorInternal.
+ *
+ * @sa      VirtualBoxBase::setError(HRESULT)
+ */
+HRESULT VirtualBoxBase::setErrorBoth(HRESULT hrc, int vrc)
+{
+    return setErrorInternal(hrc,
+                            this->getClassIID(),
+                            this->getComponentName(),
+                            Utf8Str("%Rrc", vrc),
+                            false /* aWarning */,
+                            true /* aLogIt */,
+                            vrc /* aResultDetail */);
+}
+
+/**
+ * Sets error info with a message and both a COM status and an VBox status code.
+ *
+ * The VBox status code is made available to the API user via
+ * IVirtualBoxErrorInfo::resultDetail attribute.
+ *
+ * @param   hrc             The COM status code to return.
+ * @param   vrc             The VBox status code.
+ * @param   pcszMsgFmt      Error message format string.
+ * @param   ...             Argument specified in the @a pcszMsgFmt
+ * @return  Most likely @hrc, see setErrorInternal.
+ *
+ * @sa      VirtualBoxBase::setError(HRESULT, const char *, ...)
+ */
+HRESULT VirtualBoxBase::setErrorBoth(HRESULT hrc, int vrc, const char *pcszMsgFmt, ...)
+{
+    va_list va;
+    va_start(va, pcszMsgFmt);
+    hrc = setErrorInternal(hrc,
+                           this->getClassIID(),
+                           this->getComponentName(),
+                           Utf8Str(pcszMsgFmt, va),
+                           false /* aWarning */,
+                           true /* aLogIt */,
+                           vrc /* aResultDetail */);
+    va_end(va);
+    return hrc;
+}
+
+/**
  * Like setError(), but sets the "warning" bit in the call to setErrorInternal().
  * @param aResultCode
