タスク マネージャーを使用して、次のコードに GDI リークがあることに気付きました。このコードを実行するプロセスの GDI オブジェクトの数は、実行するたびに 1 ずつ増加しますが、問題が見つからないようです。
どんな助けでも大歓迎です。
// create new DC based on current
HDC hDC = CreateCompatibleDC(GetDC());
// select a bitmap into the new DC and keep the old one
HGDIOBJ hOldObj = SelectObject (hDC,hBM);
// do somthing here --> 100% no leak here
SomeFunction (hDC);
// select the old object back from whence it came and delete whats returned
DeleteObject (SelectObject (hDC,hOldObj));
// delete the DC
DeleteDC(hDC);
// delete the tmp object
DeleteObject (hOldObj);
RM