Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. ATL DLL Newbie Question

ATL DLL Newbie Question

Scheduled Pinned Locked Moved ATL / WTL / STL
questionc++tutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    James Spibey
    wrote on last edited by
    #1

    Hey Guys, I'm trying to port a plain WIN32 dll over to another system which uses ATL to implement the interface. I know nothing about ATL but I've sort of got it working aside from the fact I can't figure out how to get the HINSTANCE of my DLL. The DLLmain does the following

    CComModule _Module;

    BEGIN_OBJECT_MAP(ObjectMap)
    OBJECT_ENTRY(CLSID_My_Plugin, CMyPlugin)
    END_OBJECT_MAP()

    BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
    {
    if (dwReason == DLL_PROCESS_ATTACH)
    {
    _Module.Init(ObjectMap, hInstance);
    DisableThreadLibraryCalls(hInstance);
    }
    else if (dwReason == DLL_PROCESS_DETACH)
    _Module.Term();
    return TRUE; // ok
    }

    I can see the _Module gets the HINSTANCE here but how do I get to it from the CMyPlugin class? Cheers James

    C 1 Reply Last reply
    0
    • J James Spibey

      Hey Guys, I'm trying to port a plain WIN32 dll over to another system which uses ATL to implement the interface. I know nothing about ATL but I've sort of got it working aside from the fact I can't figure out how to get the HINSTANCE of my DLL. The DLLmain does the following

      CComModule _Module;

      BEGIN_OBJECT_MAP(ObjectMap)
      OBJECT_ENTRY(CLSID_My_Plugin, CMyPlugin)
      END_OBJECT_MAP()

      BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
      {
      if (dwReason == DLL_PROCESS_ATTACH)
      {
      _Module.Init(ObjectMap, hInstance);
      DisableThreadLibraryCalls(hInstance);
      }
      else if (dwReason == DLL_PROCESS_DETACH)
      _Module.Term();
      return TRUE; // ok
      }

      I can see the _Module gets the HINSTANCE here but how do I get to it from the CMyPlugin class? Cheers James

      C Offline
      C Offline
      Charles Spirz
      wrote on last edited by
      #2

      _Module.GetModuleInstance();)

      J 1 Reply Last reply
      0
      • C Charles Spirz

        _Module.GetModuleInstance();)

        J Offline
        J Offline
        James Spibey
        wrote on last edited by
        #3

        :-O Thanks. Didn't realise it was that straightforward. Cheers James

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups