Getting the screen resolution as the system user
Posted: Wed Dec 21, 2011 1:53 pm
This is probably more of a windows problem than a purebasic one, but I'll ask here in case anyone has run into it...
I have a PB program which generates desktop wallpaper, either for the user, or for the pre-login desktop. If the program is run interactively as a user with appropriate privileges, both the user and prelogin wallpaper can be generated and set just fine.
However, for various reasons, I need to replace the pre-login wallpaper once a day, and do so before the first user of the day comes up to the machine. So, I've tried running my program as a scheduled task, under the SYSTEM account, purely for the purpose of replacing the pre-login wallpaper.
When my program is run this way, DesktopWidth and DesktopHeight return different values for the screen resolution. In the case of my test machine, there is a single monitor connected via DVI, running at 1280x1024. DesktopWidth and DesktopHeight return 1280 and 1024 in normal use by a logged in user. When run by the scheduled task, they return 1024 and 768 respectively, even though the pre-login environment is 1280 x 1024. This results in a wallpaper of the wrong resolution being stretched to fit. (All on Win7 32bit. I've not tested on other OSs, as Win7 is where I need it to work.)
So, there seems to be something different about running as a scheduled task and/or as the system account. The only question is what is that difference and how do I find out the real screen res from that environment? Anyone run into this and have any words of wisdom?
The only thing I've thought of so far is a workaround - record the real resolution when a user is logged in, and use that, rather than looking it up on the fly, but that seems a bit hacky.
I have a PB program which generates desktop wallpaper, either for the user, or for the pre-login desktop. If the program is run interactively as a user with appropriate privileges, both the user and prelogin wallpaper can be generated and set just fine.
However, for various reasons, I need to replace the pre-login wallpaper once a day, and do so before the first user of the day comes up to the machine. So, I've tried running my program as a scheduled task, under the SYSTEM account, purely for the purpose of replacing the pre-login wallpaper.
When my program is run this way, DesktopWidth and DesktopHeight return different values for the screen resolution. In the case of my test machine, there is a single monitor connected via DVI, running at 1280x1024. DesktopWidth and DesktopHeight return 1280 and 1024 in normal use by a logged in user. When run by the scheduled task, they return 1024 and 768 respectively, even though the pre-login environment is 1280 x 1024. This results in a wallpaper of the wrong resolution being stretched to fit. (All on Win7 32bit. I've not tested on other OSs, as Win7 is where I need it to work.)
So, there seems to be something different about running as a scheduled task and/or as the system account. The only question is what is that difference and how do I find out the real screen res from that environment? Anyone run into this and have any words of wisdom?
The only thing I've thought of so far is a workaround - record the real resolution when a user is logged in, and use that, rather than looking it up on the fly, but that seems a bit hacky.