Jump to content

dllcall & user32.dll & SystemParametersInfo


babou
 Share

Recommended Posts

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
Link to comment
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
Link to comment
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

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

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))

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...