I am trying to use shdocvw in a managed C++ program. I have read COM Interop using managed C++ - CodeProject. I used the instructions in How to add references to a managed Visual C++ project to create Interop.shdocvw.dll. I moved the file to my project directory. I am using VS 2010 Professional. I added:
#using "Interop.shdocvw.dll"
to my program. In my program I have:
SHDocVw::ShellWindows swList;
I am getting the error:
error C2653: 'SHDocVw' : is not a class or namespace name
I have also tried using a "using namespace" but that does not work either.
I am not getting an error from the #using so it is finding the file. I assume I am close to getting it to work; what am I missing?
I cannot imagine why this doesn't work, other than something drastically going wrong when you ran the tlbimp.exe utility. There's no need to do this, you can also do it with the IDE.
Right-click the project in the Solution Explorer window, Properties, Common Properties, Framework and References. Click the Add New Reference button. Browse tab, navigate to c:\windows\system32\shdocvw.dll. You should now have no trouble using the SHDocVw namespace. Troubleshoot with View + Object Browser.
And don't forget that interfaces are reference types, you need the hat:
SHDocVw::ShellWindows^ swList;