fisofo Posted January 18, 2007 Share Posted January 18, 2007 (edited) What... the.... crap. This aught to be easy, but I just can't seem to get this code to work:$dll = DllOpen("user32.dll") $DISPLAY_DEVICE = "int;char[32];char[128];int;char[128];char[128]" Dim $dd = DllStructCreate($DISPLAY_DEVICE) ; As DISPLAY_DEVICE DllStructSetData($dd, 1, DllStructGetSize($dd)) ; $dd.cb = Len($dd) $dev = 0 $EnumDisplays = DllCall($dll, "int", "EnumDisplayDevices", "str", 0, "int", $dev, "ptr", DllStructGetPtr($dd), "int", 0) if $EnumDisplays[0] = 0 then msgbox(0,"","true") else msgbox(0,"","false") endif DllClose($dll) this always returns true. I'm trying to pass a NULL to the first parameter (the "str" parameter) so that I get my display devices, and I've seen the code work in VB/C++, but no matter what I put in it either returns 0 every time, or gets a fatal error Here is the msdn article for the dll, can anyone shed some light on this?!?edit: apparently dword should be int. But it still doesn't work. Sigh. Edited January 18, 2007 by fisofo Link to comment Share on other sites More sharing options...
fisofo Posted January 18, 2007 Author Share Posted January 18, 2007 Good Morning! *Bump* Wake up, it's time to answer my question! Link to comment Share on other sites More sharing options...
fisofo Posted January 18, 2007 Author Share Posted January 18, 2007 Changed str to ptr... just a guess and worked... although I think str should have worked... Global Const $DISPLAY_DEVICE = "int;char[32];char[128];int;char[128];char[128]" Global $dd = DllStructCreate($DISPLAY_DEVICE) ; As DISPLAY_DEVICE Global $dev = 0 DllStructSetData($dd, 1, DllStructGetSize($dd)) $EnumDisplays = DllCall("user32.dll", "int", "EnumDisplayDevices", "ptr", 0, "int", $dev, "ptr", DllStructGetPtr($dd), "int", 0) msgbox(0,$EnumDisplays[0],DLLStructGetData($dd,2)) Lar. Let me just say, officially, that you rock. In case you didn't know. Thanks for the help! Link to comment Share on other sites More sharing options...
fisofo Posted January 19, 2007 Author Share Posted January 19, 2007 (edited) Wow, the support forum is sure busy these days...Well, Larry's adjustment got me further, but now I'm shooting higher and falling short. Here's the code:Global Const $DISPLAY_DEVICE_MIRRORING_DRIVER = 0x00000008 Global Const $ENUM_CURRENT_SETTINGS = -1 Global Const $ENUM_REGISTRY_SETTINGS = -2 Global Const $DEVMODE = "char[128];int;int;int;int;int;int[2] _ ;int;int;int;int;int;int;int;byte[32] _ ;int;int;int;int;int;int;int" ;perhaps not right? Global Const $DISPLAY_DEVICE = "int;char[32];char[128];int;char[128];char[128]" $dd = DllStructCreate($DISPLAY_DEVICE) DllStructSetData($dd, 1, DllStructGetSize($dd)) $EnumDisplays = DllCall("user32.dll", "int", "EnumDisplayDevices", "ptr", 0, "int", 0, "ptr", DllStructGetPtr($dd), "int", 0) If (DllStructGetData($dd, 4) <> $DISPLAY_DEVICE_MIRRORING_DRIVER) And (DllStructGetData($dd, 4) <> 0) Then $dm = DllStructCreate($DEVMODE) DllStructSetData($dm, 4, DllStructGetSize($dm)) ; everything works great up to here! $EnumDisplaysEx = DllCall("user32.dll", "int", "EnumDisplaySettingsEx", _ "str", DllStructGetData($dd, 2), _ "int", $ENUM_CURRENT_SETTINGS, _ "ptr", DllStructGetPtr($dm), _ "int", 0) If $EnumDisplaysEx[0] = 0 Then DllCall("user32.dll", "int", "EnumDisplaySettingsEx", _ "str", DllStructGetData($dd, 2), _ "int", $ENUM_REGISTRY_SETTINGS, _ "ptr", DllStructGetPtr($dm), _ "int", 0) EndIf Msgbox(0,"","ya! got here!") endifI'm almost positive the problem lies in the $DEVMODE struct, as I am unsure on some of the type's to use. MSDN for DEVMODE struct is here. Searching for DEVMODE in the forum finds people using it, but no one with the EnumDisplaySettingsEx, which returns much more information (I'm interested in position info that gets returned in the DEVMODE struct, specifically: POINTL dmPosition).Anyway, the code above completely crashes the running autoit process, just a warning. Any ideas?edit: made code more readable. Edited January 19, 2007 by fisofo Link to comment Share on other sites More sharing options...
fisofo Posted January 19, 2007 Author Share Posted January 19, 2007 Good mornin again! Ugh, this cold sucks. *bump* Link to comment Share on other sites More sharing options...
fisofo Posted January 19, 2007 Author Share Posted January 19, 2007 My originally developped DEVMODE structure was just to quickly get a func working... I did some research... and perhaps it should look like... Global Const $DEVMODE = "byte[32];short;short;short;short;int;short;short;short" & _ ";short;short;short;short;short;short;short;short;short;short;byte[32]" & _ ";short;ushort;int;int;int;int" "Samsonite! I was way off" Nicely done, I didn't know shorts/ushorts could be specified for the struct statements. Thank you for the assistance good sir! Your attention has been most helpful. Here, go buy yourself somethin' nice: Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now