CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 1999
    Posts
    5

    SHGetFileInfo BUG



    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



  2. #2
    Join Date
    Apr 1999
    Posts
    24

    Re: SHGetFileInfo BUG

    // 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()!");
    }



  3. #3
    Join Date
    Jul 2000
    Location
    France and Germany (Strasbourg and Karlsruhe)
    Posts
    134

    Re: SHGetFileInfo BUG

    What about >
    Code:
    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 !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured