ATL/COM: Defining a COM interface that won't be available outside of the DLL?

Answering my own question for the benefit of anyone who finds this thread in the future. However, please note that I am just guessing here, based on experimentation... it seems to work, at least in my specific situation, but I don't know.

First, in some appropriate header file (perhaps Hidden.h), put the following, replacing a newly generated UUID with a newly generated UUID:

#ifndef __Hidden_h__
#define __Hidden_h__

extern "C" {

#ifndef __IHidden_FWD_DEFINED__
#define __IHidden_FWD_DEFINED__
typedef interface IHidden IHidden;
#endif // __IHidden_FWD_DEFINED__

#ifndef __IHidden_INTERFACE_DEFINED__
#define __IHidden_INTERFACE_DEFINED__

EXTERN_C const IID IID_IHidden;

MIDL_INTERFACE("a newly generated UUID")  
IHidden : public IUnknown
{
    public:
        virtual HRESULT STDMETHODCALLTYPE get_Something (
            long __RPC_FAR *pVal ) = 0; 
};

#endif // __IHidden_INTERFACE_DEFINED__

}

#endif // __Hidden_h__

For how to define other types of parameters and such for a function, refer to the C++ header that was generated by MIDL from your IDL file.

Next, in the header for any class that you want to implement this interface, add the interface to the class declaration:

class ATL_NO_VTABLE CBlah :
   public CComObjectRootEx<CComSingleThreadModel>,
   public CComCoClass<CBlah, &CLSID_CBlah>,
   public ISupportErrorInfo,
   public IConnectionPointContainerImpl<CBlah>,
   public IBlah,
   public IHidden

Also add it to the COM_MAP:

BEGIN_COM_MAP(CBlah)
   COM_INTERFACE_ENTRY(IBlah)
   COM_INTERFACE_ENTRY(ISupportErrorInfo)
   COM_INTERFACE_ENTRY(IConnectionPointContainer)
   COM_INTERFACE_ENTRY(IHidden)
END_COM_MAP

And from there on out it's just a matter of adding the standard C++ declarations and definitions of the interface's functions to the class:

public:
   STDMETHOD(get_Something)(long *pVal);

(...)

STDMETHODIMP CBlah::get_Something(long *pVal)
{
   if ( !pVal )
   {
      (error handling)
   }

   *pVal = 37;

   return S_OK;
}

I hope this helps someone in the future. I also hope that it doesn't hurt me due to it being incorrect. As I said, though, it seems to work.