| C++ |
| pEntry = NULL |
| The object is destroyed immediately. |
| C# |
| System.Runtime.InteropServices.Marshal.ReleaseComObject(oEntry) |
| oEntry = null |
| By assigning the object to null the object is released (the reference count is decremented) but not destroyed. The garbage collector decides when the object is actually destroyed. Adding the ReleaseComObject-statement speeds up the actual destruction of the object. |
| VBS |
| Set oEntry = Nothing |
| The object is destroyed immediately. |
| VBN |
| System.Runtime.InteropServices.Marshal.ReleaseComObject(oEntry) |
| oEntry = Nothing |
| By assigning the object to Nothing the object is released (the reference count is decremented) but not destroyed. The garbage collector decides when the object is actually destroyed. Adding the ReleaseComObject-statement speeds up the actual destruction of the object. |