TripleB Posted July 19, 2004 Posted July 19, 2004 Hello everyone, I'm trying to obtain the file associated icon, I know that i can do this with the api function SHgetFileInfo but I can't get it to work in C++ .net what i have so far is [structLayoutAttribute(LayoutKind::Sequential)] __gc struct SHFILEINFO { public: const static int NAMESIZE = 80; IntPtr hIcon; int iIcon; unsigned int dwAttributes; String* szDisplayName; String* szTypeName; }; [DllImportAttribute("Shell32.dll",CharSet=CharSet::Auto)] extern "C" unsigned int* SHGetFileInfo(String* pszPath,unsigned int dwFileAttributes,SHFILEINFO* psfi,unsigned int cbFileInfo,unsigned int uFlags); int _tmain(void) { SHFILEINFO* sfi; SHGetFileInfo("c:\\test.txt",FILE_ATTRIBUTE_NORMAL,sfi,Marshal::SizeOf(__typeof(SHFILEINFO)),SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES); return 0; } It runs whitout erros but the SHFILEINFO struct sfi remains empty and I haven't got a clue why , I am fairly new to C++ and .Net so every help is realy appreciated. Thanx in advance, Quote
Recommended Posts