Archive: Screensize


Screensize
Hi, doe anyone know where to find the screensize of Windows?
(So 800x600, 1024x768, 1280x1024, ...)

Thx, greetz,
-Hendri.


Hey Hendri.

I certainly hope the following info. helps you - I really appreciate all the info. you have provided on this forum. :)

Anyway, on a win98 machine with multiple users this is what I found:

The desktop size is stored in a 'Resolution' string in:
HKEY_CURRENT_USER\Display\Settings
HKEY_LOCAL_MACHINE\Config\0001\Display\Settings
HKEY_USERS\crashbox\Display\Settings
HKEY_CURRENT_CONFIG\Display\Settings

I think the HKEY_CURRENT_USER\Display\Settings Resolution key is the most useful one since it will be valid at installation time...

I hope a similar key exists under NT-based platforms. I can't verify that until the evening though - if no one else has checked under NT, I will do so and let you know tonight.

Take care,

Omar


Hi Omar,

I certainly hope the following info. helps you - I really appreciate all the info. you have provided on this forum.
Thx a lot for the nice words.:)

The keys you found are a part of the solution. I cannot verify it, but I believe you're right. My problem: I cannot find similar keys on my Win2k machine. So I really appreciate if you would let me know if you find something for NT/2K.

Thx a lot in advance, greetz from Holland,
Hendri.

Hi Omar,

using your keyword "Resolution" I found the following key:
HKEY_CURRENT_CONFIG\System\CurrentControlSet\SERVICES\SISV\DEVICE0

Do you think this will work in general on any Windows machine. I think it will work for different users on a Win2K machine, but what about win98, winNt. Could you please check this?

Thx a lot! Greetz,
Hendri.


Hi Hendri. :)

I'm sorry, the key you mentioned:
HKEY_CURRENT_CONFIG\System\CurrentControlSet\SERVICES\SISV\DEVICE0

doesn't exist in '98 - It goes as far as:
HKEY_CURRENT_CONFIG\System\CurrentControlSet

But contains no SERVICES subkey. :(

Maybe it's not so bad though - if
HKEY_CURRENT_USER\Display\Settings with the 'Resolution' key contains res. info on 9x, and
HKEY_CURRENT_CONFIG\System\CurrentControlSet\SERVICES\SISV\DEVICE0 contains res. info on NT/2k/XP, then all you have to do is check the OS.

If it's 9x, get the resolution from HKEY_CURRENT_USER\Display\Settings, otherwise from HKEY_CURRENT_CONFIG\System\CurrentControlSet\SERVICES\SISV\DEVICE0

Hopefully that would work, provided we can be sure those keys will definitely exist in the respective operating systems.

Hope that works! :D


Hey Hendri.

I just wanted to clarify that I can only test on 98, 2k, and XP, not NT.

But I did find some info. on NT which leads me to believe that you won't have any problems on NT.

At this site you will find many useful batch files, for example batch files that display resolution information. The batch files are using regedit to read resolution information from:
HKEY_CURRENT_CONFIG\System\CurrentControlSet\Services

I'm attaching the relevant batch file in case you're interested.


Hmm bad news - on XP HKEY_CURRENT_CONFIG\System\CurrentControlSet\SERVICES\SISV\DEVICE0 doesn't exist. It's fine up to SERVICES, but there's no SISV subkey. :(


Hi Omar,

thx for all the effort. I think this is going to be a hell of a job. I just wanted to know the resolution to install some wallpaper for windows. I have three formats of the picture and wanted to automate the installation. But it seems a rather difficult job (determine OS first then some functions for each OS...) The batch file you posted does work, but only for NT 4...

Another idea: ReadEnvStr
Does you know if this will work?

Otherwise I will create an installer using InstOpts to select the proper wallpaper.

But I would really like to automate this...

Thx again Omar,
I'll also check MSDN, maybe they have an idea.

Greetz, Hendri.


Hi Hendri.

This is unfortunate indeed. It's really odd - I would have thought that information on desktop resolution would be stored at some sensible place in the registry. At the very least I thought it would be in a certain key on 9x, and a certain key on NT/2k/XP, but that doesn't seem to be the case - unless I'm missing something. ;)

RedEnvStr - this won't work on 9x, there's no resolution info. in the default 9x environment variables. I don't think that NT/2k/XP env. vars. have such info. either.

It really is a pity, you might have to settle for using InstallOpts - thank goodness that we at least have that! :)

Checking MSDN sounds like a good idea. :up:


Nothing found on MSDN...

I decided to supply a zip-file instead, since it also seemed insufficient to change reg settings to a new wallpaper and refreshing the desktop. It will not load the new desktop. So reboot would be needed to change the desktop wallpaper. But I don't want to do that. So the user will need to install the background itself...

Anyone an idea about loading the new wallpaper???

Thx, greetz,
Hendri.


Hi Hendri!

Try using Window's API function SystemParametersInfo (with an external DLL) with SPI_SETGRIDGRANULARITY and SPI_SETDESKWALLPAPER. I think it should work.

KiCHiK


Hi KiCHiK,

thx for the idea. But I cannot implement it because i've never heard of this. Is this possible using Delphi?

Thx, Hendri.


I think you can... I don't really know Delphi, but I have seen some source codes of it, and I think I saw Window's API calls. Search MSDN for this API call for more information.

KiCHiK


I found that screen.width in Delphi will give the width of the desktop screen. But I couldn't find anything about setting the wallpaper. BTW, I have delphi 4.

Does anyone know how to do this in Delphi?

Thx, greetz,
Hendri.


Here is a FAQ about using Win32 API with Delphi:
http://www.used-disks.com/Programmin...al/FAQ/WinAPI/

It even has the code you need :)

KiCHiK


using your keyword "Resolution" I found the following key: HKEY_CURRENT_CONFIG\System\CurrentControlSet\SERVICES\SISV\DEVICE0
Problem is that SISV is the gfxcard used in the system.
If you look at another computer that have another card, SISV would be
exchanged by something else, ie:

I81X\DEVICE0 # for example, Intel 81x gfx card
S3SAVAGE4\DEVICE0
TRID3D\DEVICE0
VGASAVE\DEVICE0

Below is the values I guess you want to extract from the registry.

Name Type Data
---------------------------------------------------------------------
DefaultSettings.BitsPerPel reg_dword 0x00000018 (24)
DefaultSettings.VRefresh reg_dword 0x00000055 (85)
DefaultSettings.XResolution reg_dword 0x00000400 (1024)
DefaultSettings.YResolution reg_dword 0x00000300 (768)
---------------------------------------------------------------------

This states that the gfxcard is running in 1024*768, 24 Bits colors and a refresh frequency of 85 Hertz

If you use a computer that was made with Sysprep and Ghost, you would probably end up with more than one gfx card. And it would be difficult to determine which card that is the right one. I dont know where to look in the registry for the default gfx for the current computer, but I guess someone on this forum knows ..

Good luck ..

\plaz

Thx KiCHik, that's really helpfull!

Together with info at MSDN i'll try to set the wallpaper. But I don't know if this will also refresh the desktop and load the new wallpaper or that a reboot is required, but I will find out when programming this thing!

Thx plaz for your post, your right, i wanted to use these regkeys, but they will indeed not always exist...

I'm trying to build a dll now to overcome the problem.

I'll post my findings here.
Thx to you all!!!

Greetz, Hendri.


Hi all,

KiCHiK, you're solution seemed not to work when ActiveDesktop is Active (:)). And my program, which should be installed to be able to install the wallpaper, uses ActiveDesktop, so this wouldn't work unfortunately. So I went to a Borland Newsgroup and I found out another solution to set colors and background wallpaper using Delphi. The installer really works great now.

Thx for your help! Omar and Plaz, also thx for your ideas!

BTW, I created ToDoList entirely using NSIS!!!
Interested in ToDoList? Take a look at my homepage:
http://home.hetnet.nl/~HendriAdriaens


Greetz, Hendri.


Hey Hendri, ToDoList is very nice! It's amazing what can be done with NSIS! :)

Just one small problem I have though - the text colour of the ToDoList page merges in with the background (dark blue) so I can't see it. I notice it uses the current desktop colour for the background colour, but how does it decide what colour to use for text?

--
Dave.


Mmm, actually, the Run and Info pages have the orange background.

Should the ToDoList page be the same?

btw, this is in an IE window, not on the desktop - if that could be a cause...

Just noticed TDLBack too... btw, my desktop is 1152x864 ;)

--
Dave.


Thx Dave,

nice you tried ToDoList. The idea behind the colors is the following: normally, ToDoList will be at the desktop and it should be not too offencive in color. That's why it will take background color. The other pages on the contrary are only temporary on the desktop, so I wanted to create something that would last in memory :) Just my homepage style... :) But it can be adapted, just plain html files with some javascript code.

About the text color: this can be changed permanently in head.txt. These are the declarations used to build todolist.html which is on the active desktop. In a later version I will try to customize this during install to the standard text color or some other windows color. Thx for the comment!!!

About the desktop resolution. Just resize your desktop ;) No kidding, you can use 1280x1024, but then ToDoList will have to be rescaled a bit to integrate it in the desktop. The problem here is, that the wallpaper can be scaled (in principle) but the HTML not (scaling is depending on fontsize). That's why the area for ToDoList is the same size (in pixels) in every version of TDLBack. I'll try to come up with a scalable HTML...


Thx for the comments again, thx for the nice words,
greetz, Hendri.


But if you Dave or anyone else has ideas for ToDoList i'm happy to receive them at my e-mail address.

In particular, if you have ideas about scaling the HTML, this would be great, because for 800x600 the HTML is actually too big and for 1280x1024 it's too small, it's optimal for 1024x768...

Thx, greetz,
Hendri.