ATL7 and VS.NET2k3 wizard, completely stuck
-
Hi! I'm making a shell extension, adding stuff to the context menu in Windows Explorer. I can find plenty of tutorials, but everyone uses ATL3 or VC++. I've already made a shell extension using the old stuff, now I want to try using the latest. The stuff that's generated from the VS.NET 2003 ATL wizard is completely different from what I've seen. After being adviced not to use attributes (couldn't get it to work anyway) I've been trying to get the COM_MAP stuff to work, but I've not been succesfull. It generated over 10 files, but here's the main file (I think) and what I've got so far:
/* This was all generated by VS.NET ATL wizard, I've marked the few lines I've added */
// This2That.cpp : Implementation of DLL Exports.#include "stdafx.h"
#include "resource.h"
#include "This2That.h"
#include <ShlObj.h> // added---------------------class CThis2ThatModule :
public CAtlDllModuleT< CThis2ThatModule >,
public IShellExtInit // added---------------------
{
public :
DECLARE_LIBID(LIBID_This2ThatLib)
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_THIS2THAT, "{58F42B54-8108-44DF-8CBC-BE62D021D4D8}")BEGIN\_COM\_MAP(CThis2ThatModule) // added--------------------- COM\_INTERFACE\_ENTRY(IShellExtInit) // added--------------------- COM\_INTERFACE\_ENTRY\_IID(IID\_IShellExtInit, CThis2ThatModule) // added--------------------- END\_COM\_MAP( ) // added--------------------- // IShellExtInit STDMETHOD(Initialize)( LPCITEMIDLIST, IDataObject\*, HKEY ); // added---------------------
};
STDMETHODIMP CThis2ThatModule::Initialize( LPCITEMIDLIST pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID ) { return E_NOTIMPL; } // added---------------------
CThis2ThatModule _AtlModule;
// DLL Entry Point
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
hInstance;
return _AtlModule.DllMain(dwReason, lpReserved);
}// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
return _AtlModule.DllCanUnloadNow();
}// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
}// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
// registers object, typelib and all interfaces in typelib
HRESULT hr = _AtlModule.DllRegisterServer();
return hr;
}// DllUnregisterServer - Removes en
-
Hi! I'm making a shell extension, adding stuff to the context menu in Windows Explorer. I can find plenty of tutorials, but everyone uses ATL3 or VC++. I've already made a shell extension using the old stuff, now I want to try using the latest. The stuff that's generated from the VS.NET 2003 ATL wizard is completely different from what I've seen. After being adviced not to use attributes (couldn't get it to work anyway) I've been trying to get the COM_MAP stuff to work, but I've not been succesfull. It generated over 10 files, but here's the main file (I think) and what I've got so far:
/* This was all generated by VS.NET ATL wizard, I've marked the few lines I've added */
// This2That.cpp : Implementation of DLL Exports.#include "stdafx.h"
#include "resource.h"
#include "This2That.h"
#include <ShlObj.h> // added---------------------class CThis2ThatModule :
public CAtlDllModuleT< CThis2ThatModule >,
public IShellExtInit // added---------------------
{
public :
DECLARE_LIBID(LIBID_This2ThatLib)
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_THIS2THAT, "{58F42B54-8108-44DF-8CBC-BE62D021D4D8}")BEGIN\_COM\_MAP(CThis2ThatModule) // added--------------------- COM\_INTERFACE\_ENTRY(IShellExtInit) // added--------------------- COM\_INTERFACE\_ENTRY\_IID(IID\_IShellExtInit, CThis2ThatModule) // added--------------------- END\_COM\_MAP( ) // added--------------------- // IShellExtInit STDMETHOD(Initialize)( LPCITEMIDLIST, IDataObject\*, HKEY ); // added---------------------
};
STDMETHODIMP CThis2ThatModule::Initialize( LPCITEMIDLIST pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID ) { return E_NOTIMPL; } // added---------------------
CThis2ThatModule _AtlModule;
// DLL Entry Point
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
hInstance;
return _AtlModule.DllMain(dwReason, lpReserved);
}// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
return _AtlModule.DllCanUnloadNow();
}// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
}// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
// registers object, typelib and all interfaces in typelib
HRESULT hr = _AtlModule.DllRegisterServer();
return hr;
}// DllUnregisterServer - Removes en
You're adding stuff in the wrong class. You're changing the module class, which is just the global
_Module
object (or whatever ATL7 calls it). You need to add a new ATL object and modify that; aside from the wizard looking different, it's pretty much the same as ATL3.1. --Mike-- LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb -
You're adding stuff in the wrong class. You're changing the module class, which is just the global
_Module
object (or whatever ATL7 calls it). You need to add a new ATL object and modify that; aside from the wizard looking different, it's pretty much the same as ATL3.1. --Mike-- LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are DumbHehe I was just about to delete my post, I noticed that too. I checked out your article code and saw that there WAS two classes. I've compiled now and it worked. So I tried to do the same thing with Attributes, and it compiles too. Now the real job begins hehe... Thank you for replying. And thank you for all the very helpful articles here at CodeProject! :-D