Monday, October 26, 2009

Opening Explorer And Selecting A File

Can be done one of two ways.

ShellExecute(hwnd, 0, "explorer.exe", "/select,pathandfilename", NULL, SW_SHOWNORMAL);

Or:

wchar_t wpath[MAX_PATH];
MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, MAX_PATH);
ITEMIDLIST* hIdList = SHSimpleIDListFromPath(wpath);
SHOpenFolderAndSelectItems(hIdList, 0, 0, 0);
ILFree(hIdList);

Not sure as I'm a fan of the newer shell APIs.

No comments:

Post a Comment