views:

523

answers:

2

When I use the following code I get an compilation error

#import <dwmapi.lib>
#include <dwmapi.h>

I get the following error:

fatal error C1083: Cannot open type library file: 'c:\program files\microsoft sdks\windows\v7.0a\lib\dwmapi.lib': Error loading type library/DLL.

Intellisense says:

2 IntelliSense: cannot open source file "c:/users/####/documents/visual studio 2010/Projects/modlauch/modlauch/Debug/dwmapi.tlh": Bad file descriptor c:\users\####\documents\visual studio 2010\projects\modlauch\modlauch\modlauchdlg.cpp 7 1 modlauch

Does anyone know how to solve it? I'm sure that my 'dwmapi' library is fine and there is nothing wrong with it. I'm using MFC with VS2010 , but I don't think that is related to the problem. (Platform - Win32)

If I get rid of "#import" then I get "unresolved external symbol _imp_DwmExtendFrameIntoClientArea@8" error.

+4  A: 

dwmapi .lib is a type library? YOu sure its not just a plain old dll. A com lib is either .DLL or .tlb.

I think its a plain old dll. So you dont #import it you need instead

 #pragma comment(lib,"dwmapi.lib")
pm100
Thanks , that fixed it
Nick Brooks
A: 

A type library is not a normal object library.

Type libraries are typically found in DLL's, OCX files and TLB files.

The few times I #import'ed a type library it always one of those, never a .LIB file.

Use the REGTLB or REGTLIB command (you may have to look this up in Google) to register a type library in your system. It's similar to REGSVR32, but registers a type library rather than a COM component.

You can also use OLEVIEW to view the contents of a type library.

Patrick