error C2787: 'IQueryInfo' : no GUID has been associated with this object

J

Jeff F

Any thoughts on correcting this error?

Here is the source:

// PrjFileInfo.h : Declaration of the CPrjFileInfo

#pragma once
#include "resource.h" // main symbols

#include "AdvShellX.h"

#include <comdef.h>
#include <shlobj.h>

// CPrjFileInfo

class ATL_NO_VTABLE CPrjFileInfo :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CPrjFileInfo, &CLSID_PrjFileInfo>,
public IDispatchImpl<IPrjFileInfo, &IID_IPrjFileInfo, &LIBID_AdvShellXLib,
/*wMajor =*/ 1, /*wMinor =*/ 0>,
public IPersistFile,
public IQueryInfo
{
public:
CPrjFileInfo()
{
}

DECLARE_REGISTRY_RESOURCEID(IDR_PRJFILEINFO)


BEGIN_COM_MAP(CPrjFileInfo)
COM_INTERFACE_ENTRY(IPrjFileInfo)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IPersistFile)
COM_INTERFACE_ENTRY(IQueryInfo)
END_COM_MAP()


DECLARE_PROTECT_FINAL_CONSTRUCT()

HRESULT FinalConstruct()
{
return S_OK;
}

void FinalRelease()
{
}

public: // IPersistFile
STDMETHOD(GetClassID)(LPCLSID) { return E_NOTIMPL; }
STDMETHOD(IsDirty)() { return E_NOTIMPL; }
STDMETHOD(Load)(LPCOLESTR, DWORD);
STDMETHOD(Save)(LPCOLESTR, BOOL) { return E_NOTIMPL; }
STDMETHOD(SaveCompleted)(LPCOLESTR) { return E_NOTIMPL; }
STDMETHOD(GetCurFile)(LPOLESTR*) { return E_NOTIMPL; }

public: // IQueryInfo
STDMETHOD(GetInfoFlags)(DWORD*) { return E_NOTIMPL; }
STDMETHOD(GetInfoTip )(DWORD, WCHAR** );

private:
_bstr_t mFileName;
};

OBJECT_ENTRY_AUTO(__uuidof(PrjFileInfo), CPrjFileInfo)
 
K

Kim Gräsman

Hi Jeff,
#include <shlobj.h>

// CPrjFileInfo

class ATL_NO_VTABLE CPrjFileInfo :
[...]
public IQueryInfo

BEGIN_COM_MAP(CPrjFileInfo)
COM_INTERFACE_ENTRY(IPrjFileInfo)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IPersistFile)
COM_INTERFACE_ENTRY(IQueryInfo)
END_COM_MAP()

IQueryInfo is not declared with __declspec(uuid(...)), so the interface
definition doesn't have an associated IID. This means you need to do this:

#include <shlguid.h> // This carries IID_IQueryInfo

And in the COM map:
COM_INTERFACE_ENTRY_IID(IID_IQueryInfo, IQueryInfo)

Also, if you look into shlguid.h, IID_IQueryInfo is guarded in _WIN32_IE >=
0x0400:

#if (_WIN32_IE >= 0x0400)
DEFINE_SHLGUID(IID_IQueryInfo, 0x00021500L, 0, 0);
#endif

so you need to #define this symbol in your stdafx.h or something, to agree
to depend on IE4 and upwards.

Hope that helps,
Kim
 
J

Jeff F

Kim,

Thanks, I'm up and running! _WIN32_IE was defined in my stdafx.h by default
with VC71.

I would never have figured out to use COM_INTERFACE_ENTRY_IID. I've been
using an example and instructions from CodeProject which are obviously
wrong.

Thanks again, Jeff


Kim Gräsman said:
Hi Jeff,
#include <shlobj.h>

// CPrjFileInfo

class ATL_NO_VTABLE CPrjFileInfo :
[...]
public IQueryInfo

BEGIN_COM_MAP(CPrjFileInfo)
COM_INTERFACE_ENTRY(IPrjFileInfo)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IPersistFile)
COM_INTERFACE_ENTRY(IQueryInfo)
END_COM_MAP()

IQueryInfo is not declared with __declspec(uuid(...)), so the interface
definition doesn't have an associated IID. This means you need to do this:

#include <shlguid.h> // This carries IID_IQueryInfo

And in the COM map:
COM_INTERFACE_ENTRY_IID(IID_IQueryInfo, IQueryInfo)

Also, if you look into shlguid.h, IID_IQueryInfo is guarded in _WIN32_IE
=
0x0400:

#if (_WIN32_IE >= 0x0400)
DEFINE_SHLGUID(IID_IQueryInfo, 0x00021500L, 0, 0);
#endif

so you need to #define this symbol in your stdafx.h or something, to agree
to depend on IE4 and upwards.

Hope that helps,
Kim
 
Joined
Nov 24, 2005
Messages
1
Reaction score
0
Sorry, but I am a newbie and I tried to follow

your directions but when I get to:

so you need to #define this symbol in your stdafx.h or something, to agree
> to depend on IE4 and upwards.


What do I define where?

Thanks,
viperD
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top