Click here to Skip to main content
15,907,001 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralSemi Solved Pin
Kharfax3-Oct-06 7:59
Kharfax3-Oct-06 7:59 
QuestionRe: Semi Solved Pin
David Crow3-Oct-06 8:44
David Crow3-Oct-06 8:44 
AnswerRe: Semi Solved Pin
Kharfax3-Oct-06 8:53
Kharfax3-Oct-06 8:53 
GeneralRe: Semi Solved Pin
Hamid_RT4-Oct-06 7:56
Hamid_RT4-Oct-06 7:56 
GeneralRe: Semi Solved Pin
Kharfax4-Oct-06 8:00
Kharfax4-Oct-06 8:00 
AnswerRe: How to get en exe default icon Pin
Nisamudheen3-Oct-06 20:26
Nisamudheen3-Oct-06 20:26 
GeneralRe: How to get en exe default icon Pin
Kharfax4-Oct-06 8:04
Kharfax4-Oct-06 8:04 
AnswerRe: How to get en exe default icon Pin
Mark Salsbery4-Oct-06 10:08
Mark Salsbery4-Oct-06 10:08 
I use this to extract an icon (from any file, not just EXEs).
This will get the default icon from Windows if none is in the exe.

<br />
	HICON hIcon = 0;<br />
<br />
	// Try to extract an icon from the file itself<br />
<br />
	SHFILEINFO shfi;<br />
	memset(&shfi, 0, sizeof(shfi));<br />
	if (SHGetFileInfo(pszPathname,<br />
		FILE_ATTRIBUTE_NORMAL,<br />
		&shfi,<br />
		sizeof(shfi),<br />
		SHGFI_ICON | SHGFI_SMALLICON))<br />
	{<br />
		hIcon = shfi.hIcon;<br />
	}<br />
<br />
<br />
	// If no icon yet, get icon associated with the file type from the shell<br />
<br />
	if (hIcon == 0)<br />
	{<br />
		LPTSTR pszExtension = PathFindExtension(pszPathname);<br />
		CString DummyFileName;<br />
		DummyFileName = _T("dummyfile");<br />
		if (pszExtension[0] == _T('.'))<br />
			DummyFileName += pszExtension;<br />
		else<br />
			DummyFileName += _T(".");<br />
<br />
		SHFILEINFO shfi;<br />
		memset(&shfi, 0, sizeof(shfi));<br />
		if (SHGetFileInfo(DummyFileName,<br />
			FILE_ATTRIBUTE_NORMAL,<br />
			&shfi,<br />
			sizeof(shfi),<br />
			SHGFI_ICON | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES))<br />
		{<br />
			hIcon = shfi.hIcon;<br />
			*pRetImgFlags |= RECORDIMGDATAFLAG_ICONFROMSHELL;<br />
		}<br />
	}<br />
<br />
	if (hIcon)<br />
	{<br />
		...<br />


Will that work?

Mark
AnswerRe: How to get en exe default icon Pin
Mark Salsbery4-Oct-06 10:11
Mark Salsbery4-Oct-06 10:11 
GeneralRe: How to get en exe default icon Pin
Mark Salsbery4-Oct-06 10:12
Mark Salsbery4-Oct-06 10:12 
GeneralRe: How to get en exe default icon Pin
Kharfax5-Oct-06 5:08
Kharfax5-Oct-06 5:08 
GeneralRe: How to get en exe default icon Pin
Mark Salsbery5-Oct-06 7:16
Mark Salsbery5-Oct-06 7:16 
GeneralRe: How to get en exe default icon Pin
Mark Salsbery5-Oct-06 7:18
Mark Salsbery5-Oct-06 7:18 
GeneralSolved at last :D Pin
Kharfax5-Oct-06 7:43
Kharfax5-Oct-06 7:43 
GeneralRe: Solved at last :D Pin
Mark Salsbery5-Oct-06 8:03
Mark Salsbery5-Oct-06 8:03 
GeneralRe: Solved at last :D Pin
Kharfax5-Oct-06 8:28
Kharfax5-Oct-06 8:28 
QuestionContext help message loop Pin
Vlasta_3-Oct-06 4:36
Vlasta_3-Oct-06 4:36 
AnswerRe: Context help message loop Pin
PJ Arends3-Oct-06 7:55
professionalPJ Arends3-Oct-06 7:55 
GeneralRe: Context help message loop Pin
Vlasta_3-Oct-06 23:14
Vlasta_3-Oct-06 23:14 
Questionsimple question! Pin
orion45003-Oct-06 4:28
orion45003-Oct-06 4:28 
AnswerRe: simple question! Pin
James R. Twine3-Oct-06 6:48
James R. Twine3-Oct-06 6:48 
QuestionRe: simple question! Pin
David Crow3-Oct-06 6:54
David Crow3-Oct-06 6:54 
AnswerRe: simple question! Pin
Hamid_RT4-Oct-06 7:38
Hamid_RT4-Oct-06 7:38 
QuestionDifficult computer science problem Pin
Semion_N3-Oct-06 4:28
Semion_N3-Oct-06 4:28 
AnswerRe: Difficult computer science problem Pin
Chris Losinger3-Oct-06 4:37
professionalChris Losinger3-Oct-06 4:37 

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.