Sign in to follow this  
Followers 0
unknown12

DLLs...

9 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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]

Share this post


Link to post
Share on other sites

Thanks, just tried it and got "DllCall Failed".

Share this post


Link to post
Share on other sites

Unfortunately still get "DLL Call Failed"

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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]

Share this post


Link to post
Share on other sites

Not really sure what to change, its my first attempt with DLL calls :whistle:

Share this post


Link to post
Share on other sites

Ok, i've got Lod3n's working by changing int to bool, but they both still return 0. Any ideas?

Share this post


Link to post
Share on other sites

bump :whistle:

Share this post


Link to post
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
Sign in to follow this  
Followers 0