|
Thanks, i'll try that. I think this is what i need.
|
|
|
|
|
I would like to "serialize" an ICON, i.e. express it as a simple sequence of bytes
that could be written/read from a database.
A .ico file could be treated as the serialization of an ICON, but that would probably be wasteful, as a .ico file can store icon images for a variety of icon sizes, and I am just interested in one device (32x32 as it happens).
An ICONINFO structure requires two BITMAPs, one for the mask and one for the color bits.. which is a bit messy.
Is there a simple way of serializing one ICON into ONE blob ?
cheers,
Neil
|
|
|
|
|
Why not just save the color bitmap and create a mask at runtime? You could go further since all your icons will be the same size, save only the array of bits from the color bitmap, and add the bitmap headers at runtime.
|
|
|
|
|
That's a good idea.
How do I get at the BITMAP stucture, starting from an HICON ? I saw GetIconInfo(), GetBitmapBits(), but the latter function doesn't seem to tell you how much memory to allocate - so I can't see how I can use it !
Presumably it is simple to create the mask BITMAP from the color BITMAP?
cheers,
Neil
|
|
|
|
|
Try to use FindResource, LoadResource, SizeofResource (size in bytes) and LockResource (get the pointer to the first byte).
Probably you'll have to work with #pragma pack(1), but I'm not sure.
Anyway, SizeofResource+LockResource will get you a pointer to a byte array and its size; you can simply get the byte array and store in a blob (perhaps also size should be stored as well).
HRSRC hrcIcon = FindResource(hExeOrDll, MAKEINTRESOURCE(IDI_YOURICON), RT_ICON);
HGLOBAL hgl = LoadResource(hExeOrDll, hrcIcon);
LPVOID pvIcon = LockResource(hgl);
DWORD dwSizeInBytes = SizeofResource(hExeOrDll, hrcIcon);
#pragma pack(push, 1)
BYTE *pbIcon = (BYTE *)malloc(dwSizeInBytes * sizeof(BYTE));
CopyMemory((PVOID)pbIcon, pvIcon, dwSizeInBytes);
#pragma pack(pop)
free(pbIcon);
Nuclear launch detected
|
|
|
|
|
Thanks for the post.
Does this work if the ICON is loaded in externally (e.g. from a .ico file) so is not a hardcoded resource in the application ?
(I am using ExtractIcon() to create my icon from a file).
cheers,
Neil
|
|
|
|
|
Probably yes, but I am not sure.
Try using LoadImage instead of LoadIcon and pass the filename instead of MAKEINTRESOURCE, and use the returned HANDLE as HRSRC, but, again I'm not sure.
But why not opening the .ico file with CreatFile directly, and store the file bytes directly?
Nuclear launch detected
|
|
|
|
|
Thanks again. Yes, I could use the .ico file as a "serialization".
I can load an icon from a .ico file with
ExtractIcon(), but there doesn't seem to be a reverse-function - to create the .ico file from an HICON.... do you know of a function to do this?
cheers,
Neil
|
|
|
|
|
Probably CreateIcon, CreateIconFromResource and CreateIconFromResourceEx will help you. Bytes will come yet again from LoadResource.
Also, CreateIconIndirect + ICONINFO could help if you have a bitmap instead.
Nuclear launch detected
|
|
|
|
|
Hi,
Does there any API exists for finding SQL Server installation path.
Warm Regards,
Mushq
|
|
|
|
|
Hi
I am not sure whether an API exists to get the SQL Server installation path, but frm my understanding any software installed on the PC has its entry into the registry. So, inside the registry under HKLM\Softwares\Microsoft\Microsoft SQL Server u can check for the appropriate key which contains the path where SQL server has been installed.
I hope, this piece of info is of some use to u.
Thanx
|
|
|
|
|
Hi,
How to read registry entry of a remote machine.
Warm Regards,
Mushq
|
|
|
|
|
Try RegConnectRegistry(), and associated functions mentioned in its help page.
cheers,
Neil
|
|
|
|
|
|
WhiteSky wrote: Score: 2.7 (3 votes).
why people giving you one vote.. let me square it off!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
Hi Alok
well you get vote 1 to two causes
(1) if you said a wrong answer you get vote 1.
(2) if you said correct answer you get vote 1,But(of course two cause is only for me)
Im wondering sometime I see if I get a vote 5 after a shrotes time its 3 (5+1) and Im wondering why?
anyway thanks
|
|
|
|
|
WhiteSky wrote: Im wondering sometime I see if I get a vote 5 after a shrotes time its 3 (5+1) and Im wondering why?
look here http://www.codeproject.com/script/comments/faq.asp
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
first of all do you have right to that machine... i Personally believe it's better you have s/w there working same for you!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
Mushq wrote: How to read registry entry of a remote machine.
Might want to check with your network folks about this. Many network admins turn this feature off with a global policy. While a handy feature it is ripe for abuse.
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
I have a program that need a control such as VC output Textbox,but I do not know which control it is.
Thanks
lanmohsui
|
|
|
|
|
What do you need,excatly?
You can use of Edit or RichEdit for show your values
|
|
|
|
|
I want to know which control in VC interface.AS the application is in Debug state,which control is "TRace message" output textbox .
lanmoshui
|
|
|
|
|
I'm sorry I dont understand what do you need
|
|
|
|
|
lanmoshui wrote: I want to know which control in VC interface.AS the application is in Debug state,which control is "TRace message" output textbox .
lanmoshui
use Spy++ tool to find the Control!!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
I did it as you say, but this can not solve the problem .
Thank you
lanmoshui
|
|
|
|