nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID, NULL, NS_GET_IID(nsIMimeObjectClassAccess), (void **) getter_AddRefs(objAccess));
nsresult res; nsCOMPtr<nsIMimeObjectClassAccess> objAccess = do_CreateInstance(kMimeObjectClassAccessCID, &res);
COM_MimeObject_write(void *mimeObject, char *data, PRInt32 length,                      PRBool user_visible_p){  nsCOMPtr<nsIMimeObjectClassAccess>  objAccess;  PRInt32                             rc=-1;  nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,                                                     NULL, NS_GET_IID(nsIMimeObjectClassAccess),                                                     (void **) getter_AddRefs(objAccess));   if (NS_SUCCEEDED(res) && objAccess)  {     if (NS_SUCCEEDED(objAccess->MimeObjectWrite(mimeObject, data, length, user_visible_p)))      rc = length;    else      rc = -1;  }   return rc;}