Try this:
static Acad::ErrorStatus deletelayout(const CString &FileName , const CString &LayoutName)
{
Acad::ErrorStatus es;
AcDbObjectId LayoutId = AcDbObjectId::kNull;
//a Smart Pointer to the database
std::auto_ptr<AcDbDatabase> pDb(new AcDbDatabase(Adesk::kFalse));
es = pDb->readDwgFile(FileName);
if(es != Acad::eOk)
return es;
//Get the layout Dictionary from the Database
AcDbDictionaryPointer pDictionary(pDb->layoutDictionaryId(),AcDb::kForRead);
if(pDictionary.openStatus() != Acad::eOk)
return es;
//Get the Layout
es = pDictionary->getAt(LayoutName, LayoutId);
if(es != Acad::eOk)
return es;
es = pDictionary->remove(LayoutId); // remove the layout
if (es != Acad::eOk)
acutPrintf("\nError: Unable to remove layout. Error code = %s.", acadErrorStatusText(es));
//closeup
es = pDb->saveAs(FileName);
return es;
}
Cheers,
Glenn.