![]() ![]() Next we use the $systemParamInfo object and call the Static method SystemParametersInfo(). In this function, we are creating an Int32 variable to hold the value that comes back from the procedure call. $systemParamInfo::SystemParametersInfo(14, 0, $value, 0) ![]() Now all we have to do is create our Powershell functions to make use of this new in-memory assembly that has been created. I used information from the MDSN site to help figure out how to set this up. $systemParamInfo = Add-Type -memberDefinition $signature -Name ScreenSaver -passThru Next thing to do is to create a Powershell assembly and assign it to a variable. We are using the same type of code we would use in C# to create an alias call into the user32.dll file. static extern bool SystemParametersInfo(int uAction, int uParam, ref int lpvParam, int flags is pretty straightforward. To begin, you will need to set up the signature information for how Powershell can call into this library. This particular function, SystemParametersInfo, is called from the “user32.dll” library. Luckily, Microsoft has provided a pretty comprehensive list of all the things you can control as well as the values of the items you might want to view or change. In C#, you have the ability to “import” dll files to use the functions inside. So every so often, I have picked up this idea and worked at it until I finally have an answer. I had seen a couple of programs that took advantage of the technology I am going to discuss, but until just recently, I have not been able to figure out exactly how it was being done. ![]() What I am talking about is real-time updates to the screen saver timeout setting right from the Powershell console! Now, I know you can use the registry provider in Powershell to set the timeout in the registry, but you have to log off and log on or restart your machine to get that to work. I was playing around with some system changes and thought it would be cool to be able to set the screen saver timeout on my machine. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |