Jump to content

dllcall to SystemParametersInfo


Recommended Posts

Hi,

I'm just experimenting with the dllcall to SystemParametersInfo.

my goal is to turn off visual effects... you know the setting you get in

mycomputer->properties->advanced->performance settings-> adjust for best performance

$SPI_SETDESKWALLPAPER = 20
   $SPIF_UPDATEINIFILE = 0x1
   $SPIF_SENDWININICHANGE = 0x2
   $SPIF_SENDCHANGE = $SPIF_SENDWININICHANGE
   $SPI_GETUIEFFECTS = 0x103E
   $SPI_SETUIEFFECTS = 4159; 0x103F
   $SPI_SETDRAGFULLWINDOWS = 37
   Local $REG_DESKTOP= "HKEY_CURRENT_USER\Control Panel\Desktop"

;; Disabling all visual effects.
         $err = DllCall("user32.dll", "int", "SystemParametersInfo", _
            "int", $SPI_SETUIEFFECTS, _
            "int", 0, _
            "int", 0, _
            "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDWININICHANGE))
            
            If @error <> 0 Then
                MsgBox( 4096, "Dll Error!!!", "There was an error making the Dll call." & @CR & "Error Code: " & @error )
            EndIf

this does not work, and does not return any errors.

anyone know what to change to get it working?

here is the code I'm replicating to autoit:

http://www.msfn.org/board/Disabling-Visual...ost-t16997.html

it's a visual basic 6 code. however I don't have visual basic on my computer any more. I can get the walpaper api working by the way.

Edited by thor918
Link to comment
Share on other sites

Hi,

I'm just experimenting with the dllcall to SystemParametersInfo.

my goal is to turn off visual effects... you know the setting you get in

mycomputer->properties->advanced->performance settings-> adjust for best performance

$SPI_SETDESKWALLPAPER = 20
   $SPIF_UPDATEINIFILE = 0x1
   $SPIF_SENDWININICHANGE = 0x2
   $SPIF_SENDCHANGE = $SPIF_SENDWININICHANGE
   $SPI_GETUIEFFECTS = 0x103E
   $SPI_SETUIEFFECTS = 4159; 0x103F
   $SPI_SETDRAGFULLWINDOWS = 37
   Local $REG_DESKTOP= "HKEY_CURRENT_USER\Control Panel\Desktop"

;; Disabling all visual effects.
         $err = DllCall("user32.dll", "int", "SystemParametersInfo", _
            "int", $SPI_SETUIEFFECTS, _
            "int", 0, _
            "int", 0, _
            "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDWININICHANGE))
            
            If @error <> 0 Then
                MsgBox( 4096, "Dll Error!!!", "There was an error making the Dll call." & @CR & "Error Code: " & @error )
            EndIf

this does not work, and does not return any errors.

anyone know what to change to get it working?

here is the code I'm replicating to autoit:

http://www.msfn.org/board/Disabling-Visual...ost-t16997.html

it's a visual basic 6 code. however I don't have visual basic on my computer any more. I can get the walpaper api working by the way.

I don't see what's wrong, but I find some of the descriptions by Microsoft to be a bit confusing. The parameter pvParam is of type inout and the 'p' prefix suggests to me that it is a pointer. (I have been wrong about this before though). However, I wonder if it should be a pointer and only 0 if it's not used. If so then you need something like

$Bstruct = DllStructCreate("int")
DllStructSetData($Bstruct,1,0)

$err = DllCall("user32.dll", "int", "SystemParametersInfo", _
            "int", $SPI_SETUIEFFECTS, _
            "int", 0, _
            "ptr", DllStructGetPtr($Bstruct), _
            "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDWININICHANGE))

I'm not optimistic but maybe it's worth a try.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I don't see what's wrong, but I find some of the descriptions by Microsoft to be a bit confusing. The parameter pvParam is of type inout and the 'p' prefix suggests to me that it is a pointer. (I have been wrong about this before though). However, I wonder if it should be a pointer and only 0 if it's not used. If so then you need something like

$Bstruct = DllStructCreate("int")
DllStructSetData($Bstruct,1,0)

$err = DllCall("user32.dll", "int", "SystemParametersInfo", _
            "int", $SPI_SETUIEFFECTS, _
            "int", 0, _
            "ptr", DllStructGetPtr($Bstruct), _
            "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDWININICHANGE))

I'm not optimistic but maybe it's worth a try.

Thanks! :)

The code however did nothing more with your changes either.

If I only had vb6 in my system, I would try the original code and see if it does what it is suppose to do on my system.

Link to comment
Share on other sites

Why did you change the $SPI_SETUIEFFECTS constant to decimal? Also, success for this function is a non-zero return value, and I don't think you check it with @error, should be $err[0]. @error checks success/failure of the DllCall function only. You'll need to use the GetLastError for more info (according to MSDN). Try changing it back to hex and this maybe -

Const $SPI_SETDESKWALLPAPER = 20
Const $SPIF_UPDATEINIFILE = 0x0001
Const $SPIF_SENDWININICHANGE = 0x0002
Const $SPIF_SENDCHANGE = $SPIF_SENDWININICHANGE
Const $SPI_GETUIEFFECTS = 0x103E
Const $SPI_SETUIEFFECTS = 0x103F
Const $SPI_SETDRAGFULLWINDOWS = 37
Local $REG_DESKTOP= "HKEY_CURRENT_USER\Control Panel\Desktop"

;; Disabling all visual effects.
         $err = DllCall("user32.dll", "int", "SystemParametersInfoA", _
            "int", $SPI_SETUIEFFECTS, _
            "int", 0, _
            "int", 0, _
            "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDWININICHANGE))
            
            If $err[0] == 0 Then
                MsgBox( 4096, "Dll Error!!!", "There was an error making the Dll call." & @CR & "Error Code: " & $err[0] )
            EndIf
Edited by wraithdu
Link to comment
Share on other sites

Why did you change the $SPI_SETUIEFFECTS constant to decimal? Also, success for this function is a non-zero return value, and I don't think you check it with @error, should be $err[0]. @error checks success/failure of the DllCall function only. You'll need to use the GetLastError for more info (according to MSDN). Try changing it back to hex and this maybe -

Const $SPI_SETDESKWALLPAPER = 20
Const $SPIF_UPDATEINIFILE = 0x0001
Const $SPIF_SENDWININICHANGE = 0x0002
Const $SPIF_SENDCHANGE = $SPIF_SENDWININICHANGE
Const $SPI_GETUIEFFECTS = 0x103E
Const $SPI_SETUIEFFECTS = 0x103F
Const $SPI_SETDRAGFULLWINDOWS = 37
Local $REG_DESKTOP= "HKEY_CURRENT_USER\Control Panel\Desktop"

;; Disabling all visual effects.
         $err = DllCall("user32.dll", "int", "SystemParametersInfoA", _
            "int", $SPI_SETUIEFFECTS, _
            "int", 0, _
            "int", 0, _
            "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDWININICHANGE))
            
            If $err[0] == 0 Then
                MsgBox( 4096, "Dll Error!!!", "There was an error making the Dll call." & @CR & "Error Code: " & $err[0] )
            EndIf
Thanks for the reply :)

I was just testing in decimal because SPI_SETDESKWALLPAPER is in decimal, and that call I have tested successfully.

However I have tested $SPI_SETUIEFFECTS in both hex and decimal, unsuccessfull.

working SPI_SETDESKWALLPAPER-code below:

;~  ;; remove wallpaper!
         $err = DllCall("user32.dll", "int", "SystemParametersInfo", _
            "int", $SPI_SETDESKWALLPAPER, _
            "int", 0, _
            "str", "", _
            "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE))
            
            If @error <> 0 Then
                MsgBox( 4096, "Dll Error!!!", "There was an error making the Dll call." & @CR & "Error Code: " & @error )
            EndIf
Link to comment
Share on other sites

  • 4 weeks later...

I have no idea why this works today, but it does -

Const $SPI_SETUIEFFECTS = 0x103F
Const $SPIF_UPDATEINIFILE = 0x0001
Const $SPIF_SENDCHANGE = 0x0002

$ret = DllCall("User32", "int", "SystemParametersInfo", _
                        "int", $SPI_SETUIEFFECTS, _
                        "int", 0, _
                        "int", 0, _
                        "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE) _
                        )
MsgBox(0, "", $ret[0])

Does this work for anyone else, or do I have a golden work computer???

Link to comment
Share on other sites

  • 2 years later...

I have no idea why this works today, but it does -

Const $SPI_SETUIEFFECTS = 0x103F
Const $SPIF_UPDATEINIFILE = 0x0001
Const $SPIF_SENDCHANGE = 0x0002

$ret = DllCall("User32", "int", "SystemParametersInfo", _
                        "int", $SPI_SETUIEFFECTS, _
                        "int", 0, _
                        "int", 0, _
                        "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE) _
                        )
MsgBox(0, "", $ret[0])

Does this work for anyone else, or do I have a golden work computer???

Hi!

I started to need this hack again.

and yes it works perfectly with the code you posted last time.

windows just dosent update the checkboxes under "mycomputer->properties->advanced->performance settings", but it does infact do disable all effects!

a litle comical but if you try to get it back using normal gui, you can't do it. to enable it again you will have to run auto it with

$ret = DllCall("User32", "int", "SystemParametersInfo", _

"int", $SPI_SETUIEFFECTS, _

"int", 0, _

"int", 1, _

"int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE) _

)

a perhaps easier approach is to disable service Themes. I'm not sure if I lose something I need, but it does not look like that.

http://www.msfn.org/board/topic/44662-turn-off-visual-effects-as-default-works/

Edited by thor918
Link to comment
Share on other sites

I would suggest looking at _WinAPI_SystemParametersInfo() in the Help File, since it might have not been available when you started this thread 3yrs ago!

Plus to disable the theme have a look at this >>

Global $GUI = GUICreate("GUI")
Global $Button = GUICtrlCreateButton("Test", 10, 10, 80, 30)
_SetWindowTheme(-1)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
    EndSwitch
WEnd

Func _SetWindowTheme($hHandle = -1)
    Local $aReturn = DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($hHandle), "wstr", 0, "wstr", 0)
    If @error Then Return SetError(1, 1, 0)
    Return $aReturn[0]
EndFunc   ;==>_SetWindowTheme
Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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