How can I save HICON to an .ico file?

You can save HICONs with the IPicture::SaveAsFile() method. Here's a sample C++ program that uses it.

You can save HICONs with the IPicture::SaveAsFile() method. Here's a sample C++ program that uses it: #include "stdafx. H" #include #include #pragma comment(lib, "oleaut32.

Lib") HRESULT SaveIcon(HICON hIcon, const wchar_t* path) { // Create the IPicture intrface PICTDESC desc = { sizeof(PICTDESC) }; desc. PicType = PICTYPE_ICON; desc.icon. IPicture* pPicture = 0; HRESULT hr = OleCreatePictureIndirect(&desc, IID_IPicture, FALSE, (void**)&pPicture); if (FAILED(hr)) return hr; // Create a stream and save the image IStream* pStream = 0; CreateStreamOnHGlobal(0, TRUE, &pStream); LONG cbSize = 0; hr = pPicture->SaveAsFile(pStream, TRUE, &cbSize); // Write the stream content to the file if (!FAILED(hr)) { HGLOBAL hBuf = 0; GetHGlobalFromStream(pStream, &hBuf); void* buffer = GlobalLock(hBuf); HANDLE hFile = CreateFile(path, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0); if (!hFile) hr = HRESULT_FROM_WIN32(GetLastError()); else { DWORD written = 0; WriteFile(hFile, buffer, cbSize, &written, 0); CloseHandle(hFile); } GlobalUnlock(buffer); } // Cleanup pStream->Release(); pPicture->Release(); return hr; } int _tmain(int argc, _TCHAR* argv) { HICON hIcon = (HICON)LoadImage(0, L"c:\\windows\\system32\\perfcentercpl.

Ico", IMAGE_ICON, 32, 32, LR_LOADFROMFILE); if (!hIcon) return GetLastError(); HRESULT hr = SaveIcon(hIcon, L"c:\\temp\\test. Ico"); return hr; }.

Have you seen these: social.msdn.microsoft.com/Forums/en-US/v... codeguru.com/forum/showthread.php?p=733535.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions