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

how to create a PIDL from a String containing

479 views
Skip to first unread message

Santosh Gadre

unread,
Jul 30, 1997, 3:00:00 AM7/30/97
to

Hi
Does anybody know how to create a PIDL from a String containing
Full file path. Any help would be appreciated.

Thanks.
Santosh

Sridhar Balaji

unread,
Jul 30, 1997, 3:00:00 AM7/30/97
to

Santosh:

This is actually documented by microsoft - look in the MSDN
Here is a code sniplet :

//pathname = fullpath of the file/folder

LPSHELLFOLDER deskTopFolder;
HRESULT hresult = SHGetDesktopFolder(&deskTopFolder);
if (SUCCEEDED(hresult))
{
OLECHAR olepathname[MAX_PATH];


MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,pathname,-1,olepathname,MAX_PATH);


// Convert the path to an ITEMIDLIST
ULONG chEaten;
ULONG dwAttributes;
LPITEMIDLIST pidl; // this the pidl for the path name

hresult =
deskTopFolder->ParseDisplayName(NULL,NULL,olepathname,&chEaten,&pidl,&dwAttr
ibutes);

// Release desktop
deskTopFolder->Release();
}


--
Sridhar Balaji
BindView Development Corp
http://www.bindview.com

Santosh Gadre <san...@querisoft.com> wrote in article
<01bc9cd0$d5312670$7f00a8c0@reindeer>...

George Voronoff

unread,
Jul 30, 1997, 3:00:00 AM7/30/97
to

If you have access to MSDN, look at the Wicked Code article:

This article is reproduced from Microsoft Systems Journal. Copyright © 1997

by Miller Freeman, Inc. Volume 12.

Just search for IContextMenu, and Wicked.

Aditi Corporation

unread,
Jul 31, 1997, 3:00:00 AM7/31/97
to

Hi Santosh,


When developing an application that interacts with the Windows 95 shell, it
is often necessary to convert an arbitrary path to a file to an ITEMIDLIST.
This can be accomplished using the IShellFolder::ParseDisplayName API.

MORE INFORMATION

Here is an example of how to use the IShellFolder interface to convert the
path to the file README.TXT in the current directory to an ITEMIDLIST. The
example is written in C. If the program is written using C++, accessing
member functions through the lpVtbl variable is unnecessary.

LPITEMIDLIST pidl; LPSHELLFOLDER pDesktopFolder;

char szPath[MAX_PATH];
OLECHAR olePath[MAX_PATH];
ULONG chEaten;
ULONG dwAttributes;
HRESULT hr;

/ // Get the path to the file we need to convert. //
GetCurrentDirectory(MAX_PATH, szPath); lstrcat(szPath, "\\readme.txt");

/ // Get a pointer to the Desktop's IShellFolder interface. // if
(SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder))) {
//
// IShellFolder::ParseDisplayName requires the file name be in Unicode.
//
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szPath, -1,
olePath, MAX_PATH);

//
// Convert the path to an ITEMIDLIST.
//
hr = pDesktopFolder->lpVtbl->ParseDisplayName(pDesktopFolder,
NULL,
NULL,
olePath,
&chEaten,
&pidl,
&dwAttributes);
if (FAILED(hr))
{
// Handle error...
}

//
// pidl now contains a pointer to an ITEMIDLIST for .\readme.txt. This
// ITEMIDLIST needs to be freed using the IMalloc allocator returned
// from SHGetMalloc().
//

...

}

Hope this helps,

A.Vijayaraghavan
Aditi Technologies Pvt.Ltd
email:asa...@aditi.com
http://www.aditi.com

Aditi Corp was formerly known as NetQuest Inc.


James Swindell

unread,
Aug 4, 1997, 3:00:00 AM8/4/97
to

On Wed, 30 Jul 1997 14:38:07 -0700, "George Voronoff"
<geo...@island.com> wrote:

I found the published information (April 1997, Vol. 12, No. 4), yet I
am still unable to put it to any use. I applied the code that was
needed--IShell::ParseDisplayName--but still unsure of its proper use.
Anyone have a simple solution?

Raymond Chen [MS]

unread,
Aug 13, 1997, 3:00:00 AM8/13/97
to

How To Convert a File Path to an ITEMIDLIST

http://www.microsoft.com/kb/articles/q132/7/50.htm

--
(My return address is intentionally invalid to foil spammers. Delete the
".---" to get my real address. I do this on my own time with my own money;
my responses are not to be considered official technical support or advice.)

0 new messages