0

I have Visual Studio 2015. I created a Visual C++ ATL project. I named it WinHookLayer. Using Wizard I added a class and selected ATL COM+ 1.0 Component and created a class with short name HookWrapper and clicked Finish.

From class view, I added a method named SetMouseHook to HookWrapper. In HookWrapper.cpp, I see the following code generated: -

STDMETHODIMP CHookWrapper::SetMouseHook(LONG threadId, LONG* result)
{
    // TODO: Add your implementation code here
    return S_OK;
}

I added my code inside it, made the dll and registered it. Then I created a C# Windows Forms application. I added reference to WinHookLayer.tlb and also added using WinHookLayerLib; in the .cs file.

I wrote

HookWrapper hkWrapper = new HookWrapper();

Till now it works fine. But SetMouseHook function is not visible from hkWrapper.

I can see the methods "Equals", "GetHashCode", "GetType" and "ToString" but not the method I added.

Avinash
  • 385
  • 3
  • 11
  • 26
  • SetMouseHook is inside C++ dll. The C++ dll project is an ATL COM+1.0 project. I added SetMouseHook using Add method wizard. I right clicked on IHookWrapper in class view and selected Add Method. There I entered the method name as SetMouseHook. – Avinash Jan 20 '17 at 14:06
  • 1
    There is a .tlb explorer somewhere in the tools (its name escapes me, if I remember will add a comment) - check to see if it includes your method definition – Richard Critten Jan 20 '17 at 14:13
  • I checked in object viewer. Do not see the method there. – Avinash Jan 20 '17 at 14:34
  • You need to add the method to respective IDL interface. This way it is published through TLB and visible on the imports, and on the C++ side your class inherits it and your implementation is picked up. – Roman R. Jan 20 '17 at 14:37
  • Thanks. It works now. In class view of the C++ dll project, I see 3 entries for IHookWrapper. Earlier I was adding the method to some other entry. Don't know why that did not work. But when I added the method to the last entry (the entry just before IHookWrapperVtbl), then it works. – Avinash Jan 20 '17 at 15:07

0 Answers0