After much research, trial, and error, I can open an IFileOpenDialog in Windows 7 and even add a custom button. I'm a little lost as to how to catch the IFileDialogEvents. Here is relevant code and attached is my project.
#include <shobjidl.h>
#pragma comment(lib, "ole32.lib")
#pragma comment(lib, "uuid.lib")
void BrowseForFile(void)
{
HRESULT hr;
IFileOpenDialog *pfd = NULL;
hr = CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileOpenDialog, (void**)&pfd);
if (SUCCEEDED(hr))
{
IFileDialogCustomize *pfdc = NULL;
hr = pfd->lpVtbl->QueryInterface(pfd, &IID_IFileDialogCustomize, (void**)&pfdc);
if (SUCCEEDED(hr))
{
hr = pfdc->lpVtbl->AddPushButton(pfdc, 6001UL, L"Use Folder");
pfdc->lpVtbl->Release(pfdc);
}
}
if (SUCCEEDED(hr))
{
hr = pfd->lpVtbl->Show(pfd,NULL);
}
if (SUCCEEDED(hr))
{
IShellItem *pItemList = NULL;
hr = pfd->lpVtbl->GetResult(pfd, &pItemList);
if (SUCCEEDED(hr))
{
PWSTR pszPath = NULL;
hr = pItemList->lpVtbl->GetDisplayName(pItemList, SIGDN_FILESYSPATH, &pszPath);
if (SUCCEEDED(hr))
{
MessageBoxW(NULL, pszPath, L"", MB_OK);
}
pItemList->lpVtbl->Release(pItemList);
}
}
pfd->lpVtbl->Release(pfd);
}