Importing dwmapi.dll

jerro a at a.com
Sat Sep 15 19:23:35 PDT 2012


On Sunday, 16 September 2012 at 00:27:19 UTC, Ian Martinez wrote:
> I'm new to D(really new, just learned it today) and I'm making 
> a little program that I want to extend the aero glass into I've 
> written this:
> struct MARGINS {
>   int cxLeftWidth;
>   int cxRightWidth;
>   int cyTopHeight;
>   int cyBottomHeight;
> }
> HRESULT extendaeroglass(HWND handle,int left,int right,int 
> top,int bottom){
> 	MARGINS aeromargins = {left,right,top,bottom};
> 	HRESULT hr = IDOK;
> 	hr = DwmExtendFrameIntoClientArea(handle,aeromargins);

This line should be

hr = DwmExtendFrameIntoClientArea(handle,&aeromargins);

> 	return hr;
> }
> But I can't seem to figure out how to import dwmapi, I googled 
> and there was something that said I'd have to translate the 
> header file(dwmapi.h) which is 532 lines long, which I can't do 
> that well because I'm not that good at D and my C/C++ is even 
> worse and another page said I need to include the .lib 
> file(converted from COFF) in it, which I did and it still won't 
> work:
> Error:undefined identifier DwmExtendFrameIntoClientArea

The functions need to be declared if you want to use them. For c 
libraries you usually import modules that contain the 
declarations, but when there isn't one already written, you need 
to declare them yourself. You don't need to translate all of 
dwmapi.h, just the parts that you use. For 
DvmExtendFrameIntoClientArea you would do this:

extern(Windows)
     HRESULT DwmExtendFrameIntoClientArea(HWND, MARGINS*);

This tells the compiler that there is a functions with this name, 
parameter types, return type and using Windows name mangling and 
calling convention. The implementation of this function needs to 
be available when linking, which is why the .lib file is also 
needed.




More information about the Digitalmars-d mailing list