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. COM
  4. What does this code do?

What does this code do?

Scheduled Pinned Locked Moved COM
question
2 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.
  • G Offline
    G Offline
    Gerald Schwab
    wrote on last edited by
    #1

    Look near the bottom of the code snippet. I'm not sure what the code is doing, can someone explain.

    template class _com_ptr_t {
    public:
    typedef _IIID ThisIIID;
    typedef typename _IIID::Interface Interface;
    static const IID& GetIID() throw()
    {
    return ThisIIID::GetIID();
    }

    template \_com\_ptr\_t(const \_com\_ptr\_t<\_OtherIID>& p) throw(\_com\_error)
        : m\_pInterface(NULL)  
    {
        HRESULT hr = \_QueryInterface(p);
    
        if (FAILED(hr) && (hr != E\_NOINTERFACE)) {
            \_com\_issue\_error(hr);
        }
    }
    template \_com\_ptr\_t(\_InterfaceType\* p) throw(\_com\_error)
        : m\_pInterface(NULL)
    {
        HRESULT hr = \_QueryInterface(p);
    
        if (FAILED(hr) && (hr != E\_NOINTERFACE)) {
            \_com\_issue\_error(hr);
        }
    }
    
     template<> \_com\_ptr\_t(LPSTR str) throw(\_com\_error)
    {
        new(this) \_com\_ptr\_t(static\_cast (str), NULL); <<<<<<-- WHAT IS THIS LINE DOING?
    }
    ...
    

    }

    C 1 Reply Last reply
    0
    • G Gerald Schwab

      Look near the bottom of the code snippet. I'm not sure what the code is doing, can someone explain.

      template class _com_ptr_t {
      public:
      typedef _IIID ThisIIID;
      typedef typename _IIID::Interface Interface;
      static const IID& GetIID() throw()
      {
      return ThisIIID::GetIID();
      }

      template \_com\_ptr\_t(const \_com\_ptr\_t<\_OtherIID>& p) throw(\_com\_error)
          : m\_pInterface(NULL)  
      {
          HRESULT hr = \_QueryInterface(p);
      
          if (FAILED(hr) && (hr != E\_NOINTERFACE)) {
              \_com\_issue\_error(hr);
          }
      }
      template \_com\_ptr\_t(\_InterfaceType\* p) throw(\_com\_error)
          : m\_pInterface(NULL)
      {
          HRESULT hr = \_QueryInterface(p);
      
          if (FAILED(hr) && (hr != E\_NOINTERFACE)) {
              \_com\_issue\_error(hr);
          }
      }
      
       template<> \_com\_ptr\_t(LPSTR str) throw(\_com\_error)
      {
          new(this) \_com\_ptr\_t(static\_cast (str), NULL); <<<<<<-- WHAT IS THIS LINE DOING?
      }
      ...
      

      }

      C Offline
      C Offline
      czer
      wrote on last edited by
      #2

      open a new com. port but disable the interface. ---->NULL:rolleyes: czer

      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