PDA

View Full Version : GetSystemInfo() - Cant verify if 32 bit colors are available



ISDev2424
09-17-2003, 03:32 PM
We have an appication that requires 32 bit color because of complex graphics and displays. I need to check the computer to verify if 32 bit colors are available before installing the application.

The max number the "GetSystemInfo ( COLORS , nColor , sColor )" function returns is the 24 bit number (16777216).... regardless if 32 bits are available. There does not appear to be any way to verify if 32 bit colors are available with this version of IS.

Any suggestions?

Thanks a million,
ISDev

Mark at IS
09-17-2003, 04:52 PM
Include the following line at the beginning of your script to declare the needed Windows API functions:

#include "Winapi.h"

Use code like the following:

hDC = GetDC(NULL);

if (hDC != NULL) then
nColors = GetDeviceCaps(hDC, BITSPIXEL);
nColorsx = GetDeviceCaps(hDC, PLANES);

if (nColors <= nColorsx) then
nColors = nColorsx;
endif;

nvResult = 1 << nColors;
ReleaseDC(NULL, hDC);
endif;

ISDev2424
09-18-2003, 08:15 AM
Mark,

Thanks for the quick response. I am unsure what the code snippet you provided does or returns... but I will certainly research the Windows API's provided and find out.

Thanks again,
ISDEV

Mark at IS
09-18-2003, 08:29 AM
Originally posted by ISDev2424
I am unsure what the code snippet you provided does or returnsIsn't it obvious? ;-)

On further review, skip the nvResult line. nColors gives the number of color bits. (nvResult would give you the actual number of colors---but InstallScript doesn't support 32-bit numbers.)

ISDev2424
09-18-2003, 10:57 AM
Mark,

Thanks again. just one more question and I wont bother you any more.

You say "nColors gives the number of color bits" in your response. Is this the number of color bits "available" or the "current" number of color bits determined by the current settings of color depth on the computer? (8bit, 16bit, 24bit, 32bit,...)?

I posted another question on 09-17-2003 11:51 AM wanting to know how to determine the "current" color settings..... but havent had any takers yet.

Thanks very much,
Billy Matlock

Mark at IS
09-18-2003, 11:13 AM
I'm not sure. All I can glean from MSDN is that BITSPIXEL tells "how many colors are available in the current video mode."

ISDev2424
09-18-2003, 03:23 PM
Mark,

In case you or anyone else is interested.... the return value from the code you provided returns the "current" color depth... not the max available color depth on the computer.

I am digging around in the Windows API's trying to find something that returns the available colors. It seems since GetSystemInfo() is almost doing it... surely there is a way.

Thanks again,
Billy M