Click to See Complete Forum and Search --> : SHGetFileInfo BUG


Fred Hartshorn
March 29th, 1999, 06:39 AM
The following code causes the thread to exit at the close of the program with a -1. When run under the IDE (VCPP 5), either Debug or Release delays return to the editor for a second or so.


char pszPathname[] "C:\\My Documents");


SHFILEINFO shfi;


SHGetFileInfo(pszPathname, 0, &shfi, sizeof(SHFILEINFO), \

SHGFI_SMALLICON | SHGFI_SYSICONINDEX);


GetLastError() returns 18- ERROR_NO_MORE_FILES.


This occurs for any call for info on ANY file in the 'My Documents' directory.


Seems to be a MYDOCS.DLL but happens with Windows95 and 98.


Any ideas?


Thanks in advance,

Fred

Alek
April 5th, 1999, 12:50 PM
// U-f-f-f-f.
// Really has something stupidity. And I dont know exactly what.
// This example is written on C++ Builder and works normally.

SHFILEINFO shfi;
DWORD hImageList;
DWORD LastError; // <- Hmmm
HICON MyIcon;
char *pszPathname = "C:\\My Documents"; // \\Diskcln.exe
try
{
hImageList = SHGetFileInfo(pszPathname, 0, &shfi, sizeof(SHFILEINFO),
SHGFI_SMALLICON | SHGFI_SYSICONINDEX);

if (!hImageList)
ShowMessage("SHGetFileInfo fails");

MyIcon = ImageList_GetIcon((_IMAGELIST *)hImageList, shfi.iIcon, ILD_NORMAL);

Image1->Picture->Icon->Handle = MyIcon;
}
catch (...)
{
ShowMessage("Exception trown by SHGetFileInfo()!");
}

burgdavid
June 27th, 2001, 09:19 AM
What about >

LPITEMIDLIST pidl;
HRESULT hRes;
SHFILEINFO shinfo;
LPITEMIDLIST itemlist;

//MyDocuments
hRes = SHGetSpecialFolderLocation(
this->GetSafeHwnd(),
CSIDL_PERSONAL,
&pidl
);
if (SUCCEEDED(hRes))
{
VERIFY( SHGetFileInfo( (LPCSTR)pidl, NULL,
&shinfo,
sizeof(shinfo),
SHGFI_PIDL | SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX | SHGFI_SMALLICON)
);

SHFILEINFO shinfo_sel;
VERIFY( SHGetFileInfo( (LPCSTR)pidl, NULL,
&shinfo_sel,
sizeof(shinfo_sel),
SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_OPENICON | SHGFI_SMALLICON)
);
etc...


To ensure to get the good path of MyDocuments folder ?

Best regards,

David Burg.

-----------------------------------------------
Don't forget to rate the post which helps you !