Hi,
I am experiencing a problem when I use the file dialog from the website smorgasbordet. I do not understand it.
What I first did: I used the program 'as is' and it worked. Then I copied the code my own program, line by line, and got an error very soon.
The code is:
HRESULT Simple_FileOpenDialog(HWND hwndParent)
{
IFileOpenDialog *pfod = NULL; /* (IFileSaveDialog is similar) */
// Create the File Open Dialog COM object.
HRESULT hr = CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileDialog, (void **)&pfod);
The last line here gives two linker errors:
Unresolved external symbol 'CLSID_FileOpenDialog'
Unresolved external symbol 'IID_IFileDialog'
These symbols are in the file shobjidl.h which I included.
In fact, I included all headers as in the sample:
#include <windows.h>
#define COBJMACROS
#include <shobjidl.h> /* for IFileDialog, IFileOpenDialog, IFileSaveDialog */
#include <knownfolders.h> /* for known folder APIs and definitions */
#include <wchar.h>
I have no idea what I am doing wrong. Any suggestions? Would be appreciated...
Hi there!
Just including the headers is not enough, the linker should know where to find CLSID_FileOpenDialog and IID_IFileDialog (they're not exported from the default libraries).
Try adding ole32.lib and uuid.lib to the linker library list (Project Options->Linker->Library and object files), that should do the trick.
Regards!
A tool for searching GUIDs from libs
https://forum.pellesc.de/index.php?topic=7293.msg27680#msg27680
const GUID CLSID_FileOpenDialog = {0xDC1C5A9C,0xE88A,0x4DDE,0xA5,0xA1,0x60,0xF8,0x2A,0x20,0xAE,0xF7};
const GUID IID_IFileDialog = {0x42F85136,0xDB7E,0x439C,0x85,0xF1,0xE4,0x07,0x5D,0x13,0x5F,0xC8};
Thank you both.