I've read several tutorials on sites like thecodeproject, but I can't seem to find an up to date tutorial on writing a COM server using Visual Studio 2008 Pro. ATL is supposed to make this easy from what I hear, but tutorial after tutorial just leave me confused.

I am attempting to write a namespace extension for Windows. I have read numerous tutorials. I understand how COM works, and how the basic interactions between a COM client and COM server work.

So here's what happens: I set out to start my project. I create a new ATL project in Visual Studio. I check the box for DLL (I want this COM server in a DLL). I see some checkboxes that say "Support COM+ 1.0" and "Support component registrar". I have no idea what either of those mean, so I check them just in case. I click "Finish".

Then I sit there staring at my screen in awe at the 19 (WTF!!) or so files it put into my project. Holy cow. I even have 2 projects, one entitled "COM Project (I Hope)" and "COM Project (I Hope)PS". What does the PS on the end mean? Why do I have 2 projects? I dont know! Looking through them I see that Visual Studio has possibly provided default implementations of some necessary functions, however each one looks similar to this:
Code:
in "dllmain.cpp":
   CCOMProjectIHopeModule _AtlModule;

   // DLL Entry Point
   extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
   {
         hInstance;
         return _AtlModule.DllMain(dwReason, lpReserved); 
   }

in "COM Project (I Hope).cpp":
   // 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);
   }

   ....
I take the hint that Visual Studio wants me to define a class called CCOMProjectIHopeModule. Okay, how? Or possibly more important is where? Where do I put the COM map defining the interfaces I wish to implement? Did ATL provide a default implementation of IUnknown or not? I cant tell!!

If anyone could explain this to me or just post a link to a tutorial that explains how to implement this, I would be very appreciative. You'll get a hi-five, and hell, maybe even a hug.