Jump to content

DLLs...


 Share

Recommended Posts

Here is my code (using it in windows Vista):

#RequireAdmin

$p  = DllStructCreate("dword;bool")

DllStructSetData($p, 1, DllStructGetSize($p))

;make the DllCall
$ret = DllCall("dwmapi.dll","int","DwmGetColorizationColor","int",DllStructGetPtr($p))

if Not $ret[0] Then
    MsgBox(0,"DllCall Error","DllCall Failed")
    exit
EndIf

;get the returned values
$n1      = DllStructGetData($p,1)
$n2      = DllStructGetData($p,2)

;free the struct
$p =0

msgbox(0,"","Colour: " & $n1 & @CRLF & "Opacity: " & $n2 )

Any ideas as to why it doesn't return colour and opacity? (only returns 0 for both).

Here is the MSDN page: http://msdn2.microsoft.com/en-gb/library/aa969513.aspx

Link to comment
Share on other sites

I think you want two DllStructCreates, not one. I don't have Vista, so no idea if this works:

#RequireAdmin

HRESULT DwmGetColorizationColor(         
    DWORD *pcrColorization,
    BOOL *pfOpaqueBlend
);

$crColorization = DllStructCreate("dword")
$pfOpaqueBlend = DllStructCreate("bool")

DllStructSetData($crColorization,1,0)
DllStructSetData($pfOpaqueBlend,1,False)

;make the DllCall
$ret = DllCall("dwmapi.dll","int","DwmGetColorizationColor","ptr",DllStructGetPtr($crColorization),"ptr",DllStructGetPtr($pfOpaqueBlend))

Select
  case @error = 0
    msgbox(0,"","Dll call success" & @crlf)
  Case @error = 1 
   msgbox(0,"","unable to use the DLL file" & @crlf)
  Case @error = 2 
    msgbox(0,"",'unknown "return type"' & @crlf)
  Case @error = 3
    msgbox(0,"",'"function" not found in the DLL file.' & @crlf)
endselect


if Not isArray($ret) Then
    msgbox(0,"","Dll did not return an array" & @crlf)
EndIf

;get the returned values
$n1      = DllStructGetData($crColorization,1)
$n2      = DllStructGetData($pfOpaqueBlend,1)

msgbox(0,"","Colour: " & $n1 & @CRLF & "Opacity: " & $n2 )

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

Well, I dunno then. Keep playing around with it. I think it's closer than before. I modified your error trap, rather than just quitting, better to see exactly what the error is, and try and return the results anyway.

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...