Click here to Skip to main content
15,895,783 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: What is the handle count for a process in windows? Pin
Gupta Suraj11-Jan-07 2:50
Gupta Suraj11-Jan-07 2:50 
GeneralRe: What is the handle count for a process in windows? Pin
Rajesh R Subramanian11-Jan-07 2:57
professionalRajesh R Subramanian11-Jan-07 2:57 
GeneralRe: What is the handle count for a process in windows? Pin
Maximilien11-Jan-07 3:41
Maximilien11-Jan-07 3:41 
GeneralRe: What is the handle count for a process in windows? Pin
Rajesh R Subramanian11-Jan-07 17:57
professionalRajesh R Subramanian11-Jan-07 17:57 
AnswerRe: What is the handle count for a process in windows? Pin
David Leyva11-Jan-07 10:24
David Leyva11-Jan-07 10:24 
AnswerRe: What is the handle count for a process in windows? Pin
Hamid_RT11-Jan-07 20:58
Hamid_RT11-Jan-07 20:58 
GeneralRe: What is the handle count for a process in windows? Pin
Gupta Suraj11-Jan-07 22:33
Gupta Suraj11-Jan-07 22:33 
QuestionCreating .ico file from HICON Pin
neilsolent11-Jan-07 2:22
neilsolent11-Jan-07 2:22 
In a previous post I was attempting to "serialize" an HICON, i.e. save it as a blob in a file or database: the opposite operation to the ExtractIcon() operation. I have since learned how to do this (see routine below).

BUT now my problem is, this routine loses color information. When the routine is run against a true-color icon, and the buffer is saved as a .ico file, and the .ico file is reloaded with ExtractIcon(), the resulting icon has reduced to 256 colors.

I think this must be a limitation of OleCreatePictureIndirect(). How can I fix my routine?

------------------------------------------------

void SerializeIcon(const HICON icon, DWORD* size, BYTE** data)
{
LPPICTURE pPicture;
PICTDESC rPD;
rPD.cbSizeofstruct = sizeof(PICTDESC);
rPD.picType = PICTYPE_ICON;
rPD.icon.hicon = icon;
IStream* pStream = NULL;
HGLOBAL hMem = NULL;
BYTE* pMem = NULL;
long lActual;

OleCreatePictureIndirect(&rPD, IID_IPicture, FALSE, (void**) &pPicture);
CreateStreamOnHGlobal(0, TRUE, &pStream);
pPicture->SaveAsFile(pStream, TRUE, &lActual);
pPicture->Release();
GetHGlobalFromStream(pStream, &hMem);
pMem = (BYTE*) GlobalLock(hMem);
*size = GlobalSize(hMem);
*data = (BYTE*) malloc(*size);
CopyMemory(*data, pMem, *size);
GlobalUnlock(hMem);
GlobalFree(hMem);
}

------------------------------------------------

<div class="ForumSig">
cheers,
Neil</div>
AnswerRe: Creating .ico file from HICON Pin
tudorbalan10-Dec-10 1:17
tudorbalan10-Dec-10 1:17 
QuestionWhat's wrong.... [modified] Pin
Astricks11-Jan-07 2:01
Astricks11-Jan-07 2:01 
AnswerRe: What's wrong.... Pin
prasad_som11-Jan-07 2:09
prasad_som11-Jan-07 2:09 
GeneralRe: What's wrong.... Pin
Astricks12-Jan-07 0:03
Astricks12-Jan-07 0:03 
AnswerRe: What's wrong.... Pin
CPallini11-Jan-07 2:10
mveCPallini11-Jan-07 2:10 
GeneralRe: What's wrong.... Pin
Astricks12-Jan-07 0:03
Astricks12-Jan-07 0:03 
AnswerRe: What's wrong.... Pin
Eytukan11-Jan-07 2:11
Eytukan11-Jan-07 2:11 
JokeRe: What's wrong.... Pin
CPallini11-Jan-07 2:12
mveCPallini11-Jan-07 2:12 
GeneralRe: What's wrong.... Pin
Eytukan11-Jan-07 2:14
Eytukan11-Jan-07 2:14 
GeneralRe: What's wrong.... Pin
Rajesh R Subramanian11-Jan-07 2:25
professionalRajesh R Subramanian11-Jan-07 2:25 
GeneralRe: What's wrong.... Pin
Eytukan11-Jan-07 2:34
Eytukan11-Jan-07 2:34 
GeneralRe: What's wrong.... Pin
John R. Shaw11-Jan-07 14:54
John R. Shaw11-Jan-07 14:54 
GeneralRe: What's wrong.... Pin
Eytukan11-Jan-07 19:36
Eytukan11-Jan-07 19:36 
GeneralRe: What's wrong.... Pin
Hamid_RT11-Jan-07 20:57
Hamid_RT11-Jan-07 20:57 
GeneralRe: What's wrong.... Pin
Astricks12-Jan-07 0:04
Astricks12-Jan-07 0:04 
AnswerRe: What's wrong.... Pin
neilsolent11-Jan-07 2:12
neilsolent11-Jan-07 2:12 
QuestionSocket Programming Pin
SrikanthVinayak Ram11-Jan-07 1:48
SrikanthVinayak Ram11-Jan-07 1:48 

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.