Code:int NEAR SaveMyIcon( HICON hIcon) { int fh, i, iResult; UINT uiSize; DWORD dwSize; OFSTRUCT of; if (!hIcon) return FALSE; dwSize = GlobalSize(hIcon); void* lpGMem; lpGMem = GlobalLock(hIcon); fh = OpenFile ("myicon.bin", &of, OF_WRITE | OF_CREATE); if (fh == -1) // If NOT opened successfully. { MessageBox(NULL, "Unable to create file", NULL, MB_OK ); return FALSE; } uiSize = _lwrite(fh, (LPSTR)lpGMem, (UINT)dwSize); _lclose(fh); if (uiSize == -1 || uiSize < (UINT)dwSize) { MessageBox(NULL, "Unable to read file", NULL, MB_OK ); return FALSE; } }
why error




Reply With Quote