15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


MFC ShellSpace Browser Eample Problem

Raja Segar -- rsz@pc.jaring.my
Sunday, February 09, 1997

Environment : Visual C++ 4.2b , Win95, NT 4.0 Workstation

Hi there..
 I am sure many of you have tried out the enum shellspace example
 provided in Win32Dev website. MFCENUM (nam2255c.zip)

 The problem is it works fine under win95 but under NT all the names
 get truncated to 5 character. I am running the same ANSI executable
 under win95 & NT.=20

 For example "My Computer" becomes "My Co=87=87"
 That's My Co followed by 2 block characters.

 I tracked down the problem the following function:-

 if (!GetName(lpsf, lpi, SHGDN_NORMAL, szBuff))

 BTW szBuff is declared as char szBuff[256].

/***************************************************************************=
*
 *
 *    FUNCTION: GetName(LPSHELLFOLDER lpsf,LPITEMIDLIST  lpi,DWORD dwFlags,
 *                     LPSTR lpFriendlyName)
 *    PURPOSE:  Gets the friendly name for the folder=20
 *
=
 ***************************************************************************=
*/
 BOOL CMfcenumView::GetName(LPSHELLFOLDER lpsf,
                            LPITEMIDLIST  lpi,
		            DWORD dwFlags,
                            LPSTR lpFriendlyName)
 {
   BOOL   bSuccess=3DTRUE;
   STRRET str;

   if (NOERROR=3D=3Dlpsf->GetDisplayNameOf(lpi,dwFlags, &str))
   {
      switch (str.uType)
      {
         case STRRET_WSTR:          // <- Under NT this block gets Executed

            WideCharToMultiByte(CP_ACP,                 // CodePage
                                0,		        // dwFlags
                                str.pOleStr,            // lpWideCharStr
                                -1,                     // cchWideChar
                                lpFriendlyName,         // lpMultiByteStr
                                sizeof(lpFriendlyName), // cchMultiByte,
                                NULL,                   // lpDefaultChar,
                                NULL);                  // lpUsedDefaultChar

             break;
         case STRRET_OFFSET:
             lstrcpy(lpFriendlyName, (LPSTR)lpi+str.uOffset);
             break;
         case STRRET_CSTR:  // <- Under Win95 this block gets Executed
             lstrcpy(lpFriendlyName, (LPSTR)str.cStr);
             break;
         default:
             bSuccess =3D FALSE;
             break;
      }
   }
   else
      bSuccess =3D FALSE;
   return bSuccess;
}
=20
BTW when i changed the szBuff declaration as follows
char szBuff[256] =3D "Testing 1234567890";

All the names become as follows=20
 // Original Declaration -> char szBuff[256];
 "My Computer" becomes "My Co=87=87"

 // Modified -> char szBuff[256] =3D "Testing 1234567890";             =20
 "My Computer" becomes "My Cing 1234567890"

Somehow null characters are getting inserted in the after the fifth=
 character.

>From here i'm lost .. i tried playing around with the parameters but no=
 luck.
I hope someone can shed some light on this matter.

Hopefully Nancy can help out since this example was written by her.

Thanks in advance.
 (  _ \/ __)(_   )
  )   /\__ \ / /_=20
 (_)\_)(___/(____)@pc.jaring.my




Syed -- sxs296@psu.edu
Sunday, February 16, 1997

I have hit the same problem before and it's easy to fix - change all
occurences of ::GetName with SHGetFileInfo. Specify that you want friendly
name for that pidl. Remember to use fully-qualified pidl.
At 08:37 PM 2/9/97 +0800, you wrote:
>Environment : Visual C++ 4.2b , Win95, NT 4.0 Workstation
>
>Hi there..
> I am sure many of you have tried out the enum shellspace example
> provided in Win32Dev website. MFCENUM (nam2255c.zip)
>
> The problem is it works fine under win95 but under NT all the names
> get truncated to 5 character. I am running the same ANSI executable
> under win95 & NT.=20
>
> For example "My Computer" becomes "My Co=87=87"
> That's My Co followed by 2 block characters.







Become an MFC-L member | Вернуться в корень Архива |