-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugHelper.cpp
More file actions
79 lines (60 loc) · 2.18 KB
/
DebugHelper.cpp
File metadata and controls
79 lines (60 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*****************************************************************************
* Jane's F/A-18
*
* DebugHelper.cpp
*-----------------------------------------------------------------------------
* by IAM
*****************************************************************************/
#include "F18.h"
#include "grfont.h"
//#include "grfileio.h"
//Global declarations:
FILE *fp=NULL;
bool checkIfFileExist(char cRegEntry[16], char cLogFile[20])
{
//iam: function to check if a file exist - returns true (1) or false (0)
struct _stat buffer;
int result;
result = _stat(RegPath(cRegEntry,cLogFile),&buffer);
if (result == 0) return TRUE;
return FALSE;
}
void logDisplaySettings()
{
//iam: This function enumerates display settings
DWORD iDevNum = 0 ;
DWORD iModeNum = 0 ;
DISPLAY_DEVICE ddi ;
DEVMODE dmi ;
TCHAR szBuffer [100] ;
ZeroMemory (&ddi, sizeof(ddi)) ;
ddi.cb = sizeof(ddi) ;
ZeroMemory (&dmi, sizeof(dmi)) ;
dmi.dmSize = sizeof(dmi) ;
DWORD previous_settings = 0 ;
char cRegEntry[6] = "DEBUG";
char cLogFile[24] = "EnumDisplaySettings.log";
//if file exist - delete it, we start with a fresh file @ each execution...
if (checkIfFileExist(cRegEntry,cLogFile)) remove(RegPath(cRegEntry,cLogFile));
//open log file
fp = fopen(RegPath(cRegEntry,cLogFile),"a+t");
while (EnumDisplayDevices (NULL, iDevNum++, &ddi, 0))
{
while (EnumDisplaySettings (ddi.DeviceName, iModeNum++, &dmi))
{
//log entry only if resolution is 800x600 or rgeater, higher than 8bpp and skip identical settings with different refresh-rate:
if (dmi.dmPelsWidth >= 800 && dmi.dmBitsPerPel > 8 && previous_settings != dmi.dmPelsWidth+dmi.dmBitsPerPel)
{
sprintf (szBuffer, "%s (ModeIndex):%i %ix%ix%i %ihz\n",ddi.DeviceString, iModeNum,dmi.dmPelsWidth, dmi.dmPelsHeight, dmi.dmBitsPerPel, dmi.dmDisplayFrequency) ;
if (fp) fwrite(szBuffer,strlen(szBuffer),1,fp);
previous_settings = dmi.dmPelsWidth+dmi.dmBitsPerPel;
ZeroMemory (&dmi, sizeof(dmi)) ;
ddi.cb = sizeof(ddi) ;
}
}
fclose(fp);
ZeroMemory (&ddi, sizeof(ddi)) ;
ddi.cb = sizeof(ddi) ;
iModeNum = 0 ;
}
}