LPITEMIDLIST pidl;
LPCITEMIDLIST cpidl;
LPCITEMIDLIST cpidl1;
LPSHELLFOLDER pDesktopFolder;
char szPath[MAX_PATH];
OLECHAR olePath[MAX_PATH];
ULONG chEaten;
ULONG dwAttributes;
HRESULT hr;
char szPath1[MAX_PATH];
//
// Get the path to the file we need to convert.
//
// GetCurrentDirectory(MAX_PATH, szPath);
sprintf(szPath, "D://code管理//Demo");
sprintf(szPath1, "D://code管理//Demo//HookManager_src.zip");
//
// 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->ParseDisplayName(NULL,0,olePath,&chEaten,&pidl,&dwAttributes);
if (FAILED(hr))
{
AfxMessageBox("ERROR");
// Handle error.
}
cpidl = pidl;
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szPath1, -1,
olePath, MAX_PATH);
//
// Convert the path to an ITEMIDLIST.
//
hr = pDesktopFolder->ParseDisplayName(NULL,0,olePath,&chEaten,&pidl,&dwAttributes);
if (FAILED(hr))
{
AfxMessageBox("ERROR");
// Handle error.
}
cpidl1 = pidl;
HRESULT RE = CoInitialize(NULL);
int re = SHOpenFolderAndSelectItems(cpidl,1,&cpidl1,NULL);
//
// pidl now contains a pointer to an ITEMIDLIST for ./readme.txt.
// This ITEMIDLIST needs to be freed using the IMalloc allocator
// returned from SHGetMalloc().
//
//release the desktop folder object
pDesktopFolder->Release();
}