Click here to Skip to main content
15,913,179 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Dont lose focus? Pin
ThatsAlok7-Jul-04 21:56
ThatsAlok7-Jul-04 21:56 
GeneralDialog Box Pin
Ken Mazaika7-Jul-04 13:06
Ken Mazaika7-Jul-04 13:06 
GeneralCommand line arguments.. Pin
Laing,James7-Jul-04 12:17
Laing,James7-Jul-04 12:17 
GeneralRe: Command line arguments.. Pin
Graham Bradshaw7-Jul-04 12:32
Graham Bradshaw7-Jul-04 12:32 
GeneralRe: Command line arguments.. Pin
Laing,James7-Jul-04 12:37
Laing,James7-Jul-04 12:37 
GeneralPostMessage problem Pin
BlackDice7-Jul-04 11:44
BlackDice7-Jul-04 11:44 
GeneralCFrameWnd draw Pin
james6667-Jul-04 10:56
james6667-Jul-04 10:56 
GeneralNeed help for memory leak Pin
Vincent Ye7-Jul-04 10:21
Vincent Ye7-Jul-04 10:21 
Hi All,

I use the code below to load a bitmap file to my program.

void CStartupDlg::LoadPictureFile(HDC hdc, LPCTSTR szFile, CBitmap *pBitmap, CSize &mSize)
{
// open file
HANDLE hFile = CreateFile(szFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
_ASSERTE(INVALID_HANDLE_VALUE != hFile);

// get file size
DWORD dwFileSize = GetFileSize(hFile, NULL);
_ASSERTE(-1 != dwFileSize);

LPVOID pvData = NULL;
// alloc memory based on file size
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize);
_ASSERTE(NULL != hGlobal);

pvData = GlobalLock(hGlobal);
_ASSERTE(NULL != pvData);

DWORD dwBytesRead = 0;
// read file and store in global memory
BOOL bRead = ReadFile(hFile, pvData, dwFileSize, &dwBytesRead, NULL);
_ASSERTE(FALSE != bRead);

GlobalUnlock(hGlobal);

CloseHandle(hFile);

// create IStream* from global memory
LPSTREAM pstm;
HRESULT hr = CreateStreamOnHGlobal(hGlobal, TRUE, &pstm);
_ASSERTE(SUCCEEDED(hr) && pstm);

// Create IPicture from image file

hr = ::OleLoadPicture(pstm, dwFileSize, FALSE, IID_IPicture, (LPVOID *)&gpPicture); <==== It said the memory allocated here is not released.
_ASSERTE(SUCCEEDED(hr) && gpPicture);
pstm->Release();

...........................................................................


gpPicture->Release();
}

After I use "Rational Purify" to check memory leak, it reports a memory leak happened.

Could you tell me what I shd release?

Thanks in advance

Vincent
GeneralRe: Need help for memory leak Pin
David Crow7-Jul-04 10:29
David Crow7-Jul-04 10:29 
GeneralRe: Need help for memory leak Pin
Vincent Ye7-Jul-04 10:40
Vincent Ye7-Jul-04 10:40 
GeneralGDI+ to get image information Pin
pnpfriend7-Jul-04 9:59
pnpfriend7-Jul-04 9:59 
Generalgetting HBitmap handle from RBG data Pin
Omar Alvi7-Jul-04 9:50
Omar Alvi7-Jul-04 9:50 
GeneralRe: getting HBitmap handle from RBG data Pin
Antti Keskinen7-Jul-04 10:36
Antti Keskinen7-Jul-04 10:36 
GeneralRe: getting HBitmap handle from RBG data Pin
Omar Alvi7-Jul-04 20:39
Omar Alvi7-Jul-04 20:39 
GeneralRe: getting HBitmap handle from RBG data Pin
Antti Keskinen8-Jul-04 2:14
Antti Keskinen8-Jul-04 2:14 
GeneralConfiguration file in outlook Pin
BrockVnm7-Jul-04 9:46
BrockVnm7-Jul-04 9:46 
GeneralRe: Configuration file in outlook Pin
palbano7-Jul-04 10:11
palbano7-Jul-04 10:11 
GeneralRe: Configuration file in outlook Pin
BrockVnm7-Jul-04 10:29
BrockVnm7-Jul-04 10:29 
GeneralRe: Configuration file in outlook Pin
David Crow7-Jul-04 10:26
David Crow7-Jul-04 10:26 
QuestionScrollbars ?? Pin
0v3rloader7-Jul-04 8:53
0v3rloader7-Jul-04 8:53 
AnswerRe: Scrollbars ?? Pin
Edwin Brunner7-Jul-04 9:18
Edwin Brunner7-Jul-04 9:18 
AnswerRe: Scrollbars ?? Pin
Jesper Knudsen7-Jul-04 10:01
Jesper Knudsen7-Jul-04 10:01 
GeneralRe: Scrollbars ?? Pin
0v3rloader7-Jul-04 11:59
0v3rloader7-Jul-04 11:59 
GeneralRe: Scrollbars ?? Pin
Jesper Knudsen7-Jul-04 12:39
Jesper Knudsen7-Jul-04 12:39 
GeneralRe: Scrollbars ?? Pin
0v3rloader7-Jul-04 14:59
0v3rloader7-Jul-04 14:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.