Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Fail to get path of system folder

0 views
Skip to first unread message

NianHawk

unread,
Apr 23, 2006, 1:21:01 AM4/23/06
to
Hi,
I succeed in getting name of system folder but fail to get path of system
folder,
the code is shown below:
if(hr=pDesktop->GetDisplayNameOf(pID, SHGDN_INFOLDER, &Sret) ==

NO_ERROR);
StrRetToString(Sret, name);
if(hr=pDesktop->GetDisplayNameOf(pID, SHGDN_NORMAL, &Sret) ==

NO_ERROR);
StrRetToString(Sret, path);

--
Nothing impossible, Nothing sure

NianHawk

unread,
Apr 23, 2006, 1:32:01 AM4/23/06
to
Hi,
I am very sorry I post it with uncompleted description. now I correct it.

I succeed in getting name of system folder but fail to get path of system
folder, the code is shown below:
if(hr=pDesktop->GetDisplayNameOf(pID, SHGDN_INFOLDER, &Sret) ==

NO_ERROR);
StrRetToString(Sret, name);
if(hr=pDesktop->GetDisplayNameOf(pID, SHGDN_FORPARSING, &Sret) ==

NO_ERROR);
StrRetToString(Sret, path);

when the 2nd para is SHGDN_INFOLDER, I get the name "My computer", when the
2nd para is SHGDN_FORPARSING, I get the path is a series of digits instead of
real path, the series of digits is just like GUID for COM.

In above code, StrRetToString is coded like below:
void CLPDlg::StrRetToString(STRRET s, CString &sout)
{
if (s.uType == STRRET_WSTR) {

int nSz = WideCharToMultiByte (CP_OEMCP, NULL, s.pOleStr, -1,
NULL, 0, NULL, NULL);
char* pS = sout.GetBuffer(nSz+1);
WideCharToMultiByte (CP_OEMCP, NULL, s.pOleStr, -1,
pS, nSz, NULL, NULL);
sout.ReleaseBuffer();
sout = pS;
m_pMalloc->Free(s.pOleStr);
}
}

Your help would be greatly appreciated.

--

Jim Barry

unread,
Apr 23, 2006, 8:14:22 AM4/23/06
to
NianHawk wrote:
> when the 2nd para is SHGDN_INFOLDER, I get the name "My computer",
> when the 2nd para is SHGDN_FORPARSING, I get the path is a series of
> digits instead of real path, the series of digits is just like GUID
> for COM.

"My Computer" is a virtual folder, not a filesystem folder. You can't get a path for it because it simply doesn't have one. For virtual folders, the shell uses a parsing name that includes the CLSID, as you have seen. This is explained in the documentation for GetDisplayNameOf and ParseDisplayName.

--
Jim Barry, MVP (Windows SDK)

0 new messages