Changes partly based on a patch and ideas by Gregor Brunmar <gregor.brunmar@home.se>:

- Fix size argument in calls to RegQueryValueEx() (if some fails, it may not be equal to sizeof(DWORD)).
- If it's impossible to read settings from vmware's registry key, obtain current screen settings and pass them.

svn path=/trunk/; revision=28970
This commit is contained in:
Aleksey Bragin 2007-09-09 11:04:22 +00:00
parent 87351e3290
commit b4bf4d4ce9

View file

@ -203,24 +203,39 @@ static BOOL
LoadResolutionSettings(DWORD *ResX, DWORD *ResY, DWORD *ColDepth)
{
HKEY hReg;
DWORD Type, Size;
DWORD Type, Size = sizeof(DWORD);
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Services\\vmx_svga\\Device0",
0, KEY_QUERY_VALUE, &hReg) != ERROR_SUCCESS)
{
return FALSE;
DEVMODE CurrentDevMode;
/* If this key is absent, just get current settings */
memset(&CurrentDevMode, 0, sizeof(CurrentDevMode));
CurrentDevMode.dmSize = sizeof(CurrentDevMode);
if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &CurrentDevMode) == TRUE)
{
*ColDepth = CurrentDevMode.dmBitsPerPel;
*ResX = CurrentDevMode.dmPelsWidth;
*ResY = CurrentDevMode.dmPelsHeight;
return TRUE;
}
}
if(RegQueryValueEx(hReg, L"DefaultSettings.BitsPerPel", 0, &Type, (BYTE*)ColDepth, &Size) != ERROR_SUCCESS ||
Type != REG_DWORD)
{
*ColDepth = 8;
Size = sizeof(DWORD);
}
if(RegQueryValueEx(hReg, L"DefaultSettings.XResolution", 0, &Type, (BYTE*)ResX, &Size) != ERROR_SUCCESS ||
Type != REG_DWORD)
{
*ResX = 640;
Size = sizeof(DWORD);
}
if(RegQueryValueEx(hReg, L"DefaultSettings.YResolution", 0, &Type, (BYTE*)ResY, &Size) != ERROR_SUCCESS ||