Jump to content
  • Advertisement
Sign in to follow this  
TFS_Waldo

Displaying file properties dialog? (Win32/MFC)

This topic is 4861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone. I hope someone can offer me some kind of help. I just need to know how I can display the Windows File Properties dialog box for a specified file. That's all I need to know. I hope you understand what I am talking about. Thanks in advance, Matt U.

Share this post


Link to post
Share on other sites
Advertisement

#include <windows.h>
#include <shobjidl.h>
#include <shlobj.h>

int main()
{
LPOLESTR pszFile = OLESTR("c:\\boot.ini");
LPITEMIDLIST pidl;
LPCITEMIDLIST pidlItem;
HRESULT hr;
IShellFolder *pFolder;
IContextMenu *pContextMenu;
CMINVOKECOMMANDINFO cmi;

hr = SHGetDesktopFolder(&pFolder);
if (FAILED(hr)) return 0;

hr = pFolder->ParseDisplayName(HWND_DESKTOP, NULL, pszFile, NULL, &pidl, NULL);
pFolder->Release();
if (FAILED(hr)) return 0;

hr = SHBindToParent(pidl, IID_IShellFolder, (void **)&pFolder, &pidlItem);
if (FAILED(hr))
{
SHFree(pidl);
return 0;
}

hr = pFolder->GetUIObjectOf(HWND_DESKTOP, 1, (LPCITEMIDLIST *)&pidlItem, IID_IContextMenu, NULL, (void **)&pContextMenu);
pFolder->Release();
if (SUCCEEDED(hr))
{
ZeroMemory(&cmi, sizeof(cmi));
cmi.cbSize = sizeof(cmi);
cmi.lpVerb = "properties";
cmi.nShow = SW_SHOWNORMAL;

hr = pContextMenu->InvokeCommand(&cmi);

Sleep(10000); // Give the system time to show the dialog before exiting
}
pContextMenu->Release();
SHFree(pidl);

return 0;
}



Robert

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!