CDC *pMyDC = GetDC();是获得当前窗口客户区的DC,由系统来管理,你只需要使用。你说的局部变量应该是pMyDC这个指针,它是局部的,就像你 int a;一样,a也是局部,会自动销毁。
CDC *pAnotherDC = new CDC;是你自己构造的DC对象,常用来做内存dc,你首先应该创建它,然后才能使用,当然,用完了要删除;可以参考MSDN的CDC类和CreateCompatibleDC函数。
两者都获得了设备描述环境的句柄 经查MSDN 有下列语句:Unless the device context belongs to a window class, the ReleaseDC member function must be called to release the context after painting.意思是除非设备描述环境属于一个窗口类 否则都要调用ReleaseDC();查ReleaseDC之后又发现The application must call the ReleaseDC member function for each call to the GetWindowDC member function and for each call to the GetDC member function.意思是每次调用了GetDC或GetWindowDC之后都要调用它 第二种是创建了一个新对象并令pAnotherDC指向他 应该调用delete pAnotherDC;