I am trying to register BHO with APPcontainer.Now as per the blog http://blogs.msdn.com/b/ieinternals/archive/2012/03/23/understanding-ie10-enhanced-protected-mode-network-security-addons-cookies-metro-desktop.aspx
,I have defined following in same cpp file as DLLRegister
DEFINE_GUID(CATID_AppContainerCompatible, 0x59fb2056,0xd625,0x48d0,0xa9,0x44,0x1a,0x85,0xb5,0xab,0x26,0x40);
STDAPI DllRegisterServer(void)
{
// let ATL handle this
HRESULT hr = _AtlModule.DllRegisterServer();
ICatRegister* pcr = NULL ;
hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr, NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr);
if (FAILED(hr))
return hr;
if (SUCCEEDED(hr))
{
// Register this category as being "implemented" by
// the class.
CATID rgcatid[1] ;
rgcatid[0] = CATID_AppContainerCompatible;
hr = pcr->RegisterClassImplCategories(CLSID_ABC, 1, rgcatid);
}
When I try to compile this code I am getting following error:
unresolved external symbol CATID_AppContainerCompatible
Not sure why this is coming. I can navigate to CATID_AppContainerCompatible definition by right click on it. any suggesitons??
I solved the issue. since DEFINE_GUID declares GUID as extern I need to put const GUID CATID_AppContainerCompatible ;
in my file .After putting that statement its compiling.
DEFINE_GUID
behavior depends on presence of INITGUID
definition. This is a very frequent problem, so it makes no sense to repeat the details once again, here is further reading: How to avoid error "LNK2001 unresolved external" by using DEFINE_GUID.
To avoid falling into this trap you can use __declspec(uuid(...))
specifier and let compiler sort GUIDs out automatically, e.g.:
class __declspec(uuid("{26AFA816-359E-4094-90A8-BA73DE0035FA}"))
AppContainerCompatible;
// ...
rgcatid[0] = __uuidof(AppContainerCompatible); //CATID_AppContainerCompatible;
More on this: Referencing GUIDs