Sign in to follow this  
Followers 0
babou

dllcall & user32.dll & SystemParametersInfo

6 posts in this topic

#1 ·  Posted (edited)

Hi all,

I do not understand how it work, i have this example

Func _ScreenSaverActive($bBoolean)
      Local Const $SPI_SETSCREENSAVEACTIVE = 17
      Local $lActiveFlag
      
      Dim $lActiveFlag
      Dim $retvaL
      
      If $bBoolean Then
          $lActiveFlag = 1
      Else
          $lActiveFlag = 0
      EndIf
      
      $dll = DllOpen("user32.dll")
      $retvaL = DllCall($dll, "long", "<span class="searchlite">SystemParametersInfo</span>", "long", $SPI_SETSCREENSAVEACTIVE, "long", $lActiveFlag, "long", 0, "long", 0)
      DllClose($dll)
  EndFunc

I do not understand

Local Const $SPI_SETSCREENSAVEACTIVE = 17

because in msdn doc i read that the name of uiAction is SPI_SETSCREENSAVEACTIVE and in autoit script you use "17" ... How can i convert ? i would like to use "SPI_GETDESKWALLPAPER" how can i do ?

that's all

Edited by babou

Share this post


Link to post
Share on other sites



Hi all,

I do not understand how it work, i have this example

Func _ScreenSaverActive($bBoolean)
      Local Const $SPI_SETSCREENSAVEACTIVE = 17
      Local $lActiveFlag
      
      Dim $lActiveFlag
      Dim $retvaL
      
      If $bBoolean Then
          $lActiveFlag = 1
      Else
          $lActiveFlag = 0
      EndIf
      
      $dll = DllOpen("user32.dll")
      $retvaL = DllCall($dll, "long", "<span class="searchlite">SystemParametersInfo</span>", "long", $SPI_SETSCREENSAVEACTIVE, "long", $lActiveFlag, "long", 0, "long", 0)
      DllClose($dll)
  EndFunc

I do not understand

Local Const $SPI_SETSCREENSAVEACTIVE = 17

because in msdn doc i read that the name of uiAction is SPI_SETSCREENSAVEACTIVE and in autoit script you use "17" ... How can i convert ? i would like to use "SPI_GETDESKWALLPAPER" how can i do ?

that's all

Try $SPI_GETDESKWALLPAPER=115

Share this post


Link to post
Share on other sites

thanks i have found a web site

http://www.experts-exchange.com/Programmin...Q_21718714.html

now i cannot get my value

Global Const $SPI_GETDESKWALLPAPER = 115
 
 $Wallpaper = DllStructCreate("int")
 DllStructSetData($Wallpaper, 1, 0)
 DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_GETDESKWALLPAPER, "int", 0,  "ptr", DllStructGetPtr($Wallpaper), "char", 0)
 MsgBox(64, Default, DllStructGetData($Wallpaper, 1))

my messagebox return "0" ... I do not understand the mistake and not the path of my wallpaper

thanks

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Your receiving structure isn't correct:

SPI_GETDESKWALLPAPER

Retrieves the full path of the bitmap file for the desktop wallpaper. The pvParam parameter must point to a buffer to receive the NULL-terminated path string. Set the uiParam parameter to the size, in characters, of the pvParam buffer. The returned string will not exceed MAX_PATH characters. If there is no desktop wallpaper, the returned string is empty.

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Global Const $SPI_GETDESKWALLPAPER = 115
$Wallpaper = DllStructCreate("char[256]")
DllStructSetData($Wallpaper, 1, 0)
DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_GETDESKWALLPAPER, "int", 255, "ptr", DllStructGetPtr($Wallpaper), "int", 0)
MsgBox(64, Default, DllStructGetData($Wallpaper, 1))


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

thanks a lot it woks fine :)

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