/// <summary> /// <c>InitLibraries</c> /// </summary> /// <remarks> /// </remarks> /// <returns></returns> void __stdcall InitLibraries(void) { PCSTR pszFormat; PCSTR pszMessage; size_t nBufferSize; char szAssetsPathMessage[MAX_PATH * 2]; bool bbladepath1; bool bbladepath2; // char szDdrawMessage[MAX_PATH * 2]; char szDirectXVersionMessage2[128]; char szDirectXVersionMessage1[128]; char szDsetupMessage[MAX_PATH * 2]; HMODULE hModule_dsetup; char szAssetsPath[MAX_PATH]; PDIRECTXSETUPGETVERSION pDirectXSetupGetVersion; #if _CONSIDERED_OBSOLETE OSVERSIONINFOA VersionInformation; char szDirBuffer[MAX_PATH]; char szInstallMessage[256]; #endif gos_MathExceptions(false, false); // C6031: Return value ignored: 'CoInitialize' CoInitialize(nullptr); // dsetup.dll strcpy_s(szAssetsPath, _countof(szAssetsPath), AssetsDirectory2); strcat_s(szAssetsPath, _countof(szAssetsPath), "\\dsetup.dll"); hModule_dsetup = LoadLibraryA(szAssetsPath); if (hModule_dsetup == nullptr) { strcpy_s(szAssetsPath, _countof(szAssetsPath), AssetsDirectory1); strcat_s(szAssetsPath, _countof(szAssetsPath), "\\assets\\binaries\\dsetup.dll"); hModule_dsetup = LoadLibraryA(szAssetsPath); if (hModule_dsetup == nullptr) { // pszFormat = gos_GetResourceString(gLanguageDLL, 10051u); pszFormat = "Cannot find dsetup.dll in %s\\assets\\binaries or %s, " "this file is required"; sprintf_s(szDsetupMessage, _countof(szDsetupMessage), pszFormat, AssetsDirectory1, AssetsDirectory2); MessageBoxA(nullptr, szDsetupMessage, ApplicationName, MB_ICONEXCLAMATION); status = AfterExit; _exit(EXIT_FAILURE); } } pDirectXSetupGetVersion = reinterpret_cast<PDIRECTXSETUPGETVERSION>( GetProcAddress(hModule_dsetup, "DirectXSetupGetVersion")); if (pDirectXSetupGetVersion == nullptr || pDirectXSetupGetVersion(&DXdwVersion, &DXdwRevision) == 0) { DXdwVersion = 0; DXdwRevision = 0; } FreeLibrary(hModule_dsetup); // ddraw.dll if (gDirectX7) { if ((WindowsNT == false) && ((DXdwVersion < 7) || ((DXdwVersion == 7) && (DXdwRevision < 716)))) { pszFormat = "Requires DirectX 7.0a or later, found %s"; pszMessage = GetDirectXVersion(); sprintf_s(szDirectXVersionMessage1, _countof(szDirectXVersionMessage1), pszFormat, pszMessage); MessageBoxA(nullptr, szDirectXVersionMessage1, ApplicationName, MB_ICONEXCLAMATION); status = AfterExit; _exit(EXIT_FAILURE); } } else { if ((DXdwVersion < 8) || ((DXdwVersion == 8) && (DXdwRevision < 400))) { // pszFormat = gos_GetResourceString(gLanguageDLL, 10030u); // // language.dll : "Requires DirectX 8 or later, found %s" pszFormat = "Requires DirectX 8 or later, found %s"; pszMessage = GetDirectXVersion(); sprintf_s(szDirectXVersionMessage2, _countof(szDirectXVersionMessage2), pszFormat, pszMessage); MessageBoxA(nullptr, szDirectXVersionMessage2, ApplicationName, MB_ICONEXCLAMATION); status = AfterExit; _exit(EXIT_FAILURE); } } if (gNoBlade == true) { LibBlade = LoadLibraryA("ddraw.dll"); if (LibBlade == nullptr) { // pszMessage = gos_GetResourceString(gLanguageDLL, 10031u); pszMessage = "Cannot find ddraw.dll, this file is required"; // sprintf_s(szDdrawMessage, _countof(szDdrawMessage), pszMessage); MessageBoxA(nullptr, pszMessage, ApplicationName, MB_ICONEXCLAMATION); status = AfterExit; _exit(EXIT_FAILURE); } _DirectDrawCreateEx = reinterpret_cast<PDIRECTDRAWCREATEEX>(GetProcAddress(LibBlade, "DirectDrawCreateEx")); _DirectDrawEnumerate = reinterpret_cast<PDIRECTDRAWENUMERATEA>( GetProcAddress(LibBlade, "DirectDrawEnumerateA")); _DirectDrawEnumerateEx = reinterpret_cast<PDIRECTDRAWENUMERATEEXA>( GetProcAddress(LibBlade, "DirectDrawEnumerateExA")); g_pGetDXVB = nullptr; if ((_DirectDrawCreateEx == nullptr) || (_DirectDrawEnumerate == nullptr) || /* typo bug (_DirectDrawEnumerate == nullptr)*/ (_DirectDrawEnumerateEx == nullptr)) { pszMessage = "Cannot find ddraw functions"; MessageBoxA(nullptr, pszMessage, ApplicationName, MB_ICONEXCLAMATION); status = AfterExit; _exit(EXIT_FAILURE); } } else { // this special dll must surely be considered obsolete whatever the // advantages there were to use a custom ddraw library. bbladepath2 = false; bbladepath1 = true; strcpy_s(BladePath, _countof(BladePath), AssetsDirectory2); strcat_s(BladePath, _countof(BladePath), "\\bladed.dll"); LibBlade = LoadLibraryA(BladePath); if (LibBlade == nullptr) { strcpy_s(BladePath, _countof(BladePath), AssetsDirectory1); strcat_s(BladePath, _countof(BladePath), "\\assets\\binaries\\bladed.dll"); LibBlade = LoadLibraryA(BladePath); if (LibBlade == nullptr) { if (strlen(AssetsDirectory2) >= 16) { nBufferSize = strlen(AssetsDirectory2); if (!_strnicmp( &AssetsDirectory2[nBufferSize - 16], "\\assets\\binaries", 0x10u)) bbladepath2 = true; } bbladepath1 = false; strcpy_s(BladePath, _countof(BladePath), AssetsDirectory2); strcat_s(BladePath, _countof(BladePath), "\\blade.dll"); LibBlade = LoadLibraryA(BladePath); if (LibBlade == nullptr) { strcpy_s(BladePath, _countof(BladePath), AssetsDirectory1); strcat_s(BladePath, _countof(BladePath), "\\assets\\binaries\\blade.dll"); LibBlade = LoadLibraryA(BladePath); bbladepath2 = true; if (LibBlade == nullptr) { // pszFormat = gos_GetResourceString(gLanguageDLL, // 10033u); pszFormat = "Cannot find blade.dll in " "%s\\assets\\binaries or %s, this file is " "required"; sprintf_s(szAssetsPathMessage, _countof(szAssetsPathMessage), pszFormat, AssetsDirectory1, AssetsDirectory2); MessageBoxA( nullptr, szAssetsPathMessage, ApplicationName, MB_ICONEXCLAMATION); status = AfterExit; _exit(EXIT_FAILURE); } } } } if ((bbladepath2 == false) && _stricmp(ApplicationName, "Test Blade")) { if (bbladepath1 == true) { if (InternalFunctionPause("Warning, '%s' was used", BladePath)) ENTER_DEBUGGER; } else { if (gos_DoesFileExist("assets\\binaries") && InternalFunctionPause("Warning, '%s' was used", BladePath)) ENTER_DEBUGGER; } } _DirectDrawCreateEx = reinterpret_cast<PDIRECTDRAWCREATEEX>(GetProcAddress(LibBlade, "DirectDrawCreateEx")); _DirectDrawEnumerate = reinterpret_cast<PDIRECTDRAWENUMERATEA>( GetProcAddress(LibBlade, "DirectDrawEnumerateA")); _DirectDrawEnumerateEx = reinterpret_cast<PDIRECTDRAWENUMERATEEXA>( GetProcAddress(LibBlade, "DirectDrawEnumerateExA")); g_pGetDXVB = reinterpret_cast<GETDXFUNC>(GetProcAddress(LibBlade, "GetDXVB")); if ((_DirectDrawCreateEx == nullptr) || (_DirectDrawEnumerate == nullptr) || /* typo bug (_DirectDrawEnumerate == nullptr)*/ (_DirectDrawEnumerateEx == nullptr) || (g_pGetDXVB == nullptr)) { pszMessage = "Cannot find Blade functions"; MessageBoxA(nullptr, pszMessage, ApplicationName, MB_ICONEXCLAMATION); status = AfterExit; _exit(EXIT_FAILURE); } } // ijl10.dll strcpy_s(szAssetsPath, _countof(szAssetsPath), AssetsDirectory2); strcat_s(szAssetsPath, _countof(szAssetsPath), "\\ijl10.dll"); LibJpeg = LoadLibraryA(szAssetsPath); if (LibJpeg == nullptr) { strcpy_s(szAssetsPath, _countof(szAssetsPath), AssetsDirectory1); strcat_s(szAssetsPath, _countof(szAssetsPath), "\\assets\\binaries\\ijl10.dll"); LibJpeg = LoadLibraryA(szAssetsPath); } if (LibJpeg) { _ijlInit = reinterpret_cast<PIJLINIT>(GetProcAddress(LibJpeg, "ijlInit")); _ijlFree = reinterpret_cast<PIJLFREE>(GetProcAddress(LibJpeg, "ijlFree")); _ijlRead = reinterpret_cast<PIJLREAD>(GetProcAddress(LibJpeg, "ijlRead")); _ijlWrite = reinterpret_cast<PIJLWRITE>(GetProcAddress(LibJpeg, "ijlWrite")); } // dsound.dll LibDsound = LoadLibraryA("dsound.dll"); if (LibDsound == nullptr) { // pszMessage = gos_GetResourceString(gLanguageDLL, 10036u); pszMessage = "Cannot load DirectSound dll"; MessageBoxA(nullptr, pszMessage, ApplicationName, MB_ICONEXCLAMATION); status = AfterExit; _exit(EXIT_FAILURE); } _DirectSoundCreate = reinterpret_cast<PDIRECTSOUNDCREATE>(GetProcAddress(LibDsound, "DirectSoundCreate")); _DirectSoundEnumerate = reinterpret_cast<PDIRECTSOUNDENUMERATEA>( GetProcAddress(LibDsound, "DirectSoundEnumerateA")); if ((_DirectSoundCreate == nullptr) && (_DirectSoundEnumerate == nullptr)) { pszMessage = "Cannot find DirectSound functions"; MessageBoxA(nullptr, pszMessage, ApplicationName, MB_ICONEXCLAMATION); status = AfterExit; _exit(EXIT_FAILURE); } // dinput.dll LibDinput = LoadLibraryA("dinput.dll"); if (LibDinput == nullptr) { // pszMessage = gos_GetResourceString(gLanguageDLL, 10038u); pszMessage = "Cannot load DirectInput dll"; MessageBoxA(nullptr, pszMessage, ApplicationName, MB_ICONEXCLAMATION); status = AfterExit; _exit(EXIT_FAILURE); } _DirectInputCreateEx = reinterpret_cast<PDIRECTINPUTCREATEEX>(GetProcAddress(LibDinput, "DirectInputCreateEx")); if (_DirectInputCreateEx == nullptr) { pszMessage = "Cannot find DirectInput functions"; MessageBoxA(nullptr, pszMessage, ApplicationName, MB_ICONEXCLAMATION); status = AfterExit; _exit(EXIT_FAILURE); } // imm32.dll LibIME = LoadLibraryA("imm32.dll"); if (LibIME) { _ImmGetContext = reinterpret_cast<PIMMGETCONTEXT>(GetProcAddress(LibIME, "ImmGetContext")); _ImmReleaseContext = reinterpret_cast<PIMMRELEASECONTEXT>(GetProcAddress(LibIME, "ImmReleaseContext")); _ImmAssociateContext = reinterpret_cast<PIMMASSOCIATECONTEXT>(GetProcAddress(LibIME, "ImmAssociateContext")); _ImmGetCompositionString = reinterpret_cast<PIMMGETCOMPOSITIONSTRINGA>( GetProcAddress(LibIME, "ImmGetCompositionStringA")); _ImmGetOpenStatus = reinterpret_cast<PIMMGETOPENSTATUS>(GetProcAddress(LibIME, "ImmGetOpenStatus")); _ImmSetOpenStatus = reinterpret_cast<PIMMSETOPENSTATUS>(GetProcAddress(LibIME, "ImmSetOpenStatus")); _ImmGetConversionStatus = reinterpret_cast<PIMMGETCONVERSIONSTATUS>( GetProcAddress(LibIME, "ImmGetConversionStatus")); _ImmGetCandidateList = reinterpret_cast<PIMMGETCANDIDATELISTA>(GetProcAddress(LibIME, "ImmGetCandidateListA")); _ImmGetVirtualKey = reinterpret_cast<PIMMGETVIRTUALKEY>(GetProcAddress(LibIME, "ImmGetVirtualKey")); _ImmLockIMC = reinterpret_cast<PIMMLOCKIMC>(GetProcAddress(LibIME, "ImmLockIMC")); _ImmUnlockIMC = reinterpret_cast<PIMMUNLOCKIMC>(GetProcAddress(LibIME, "ImmUnlockIMCC")); _ImmLockIMCC = reinterpret_cast<PIMMLOCKIMCC>(GetProcAddress(LibIME, "ImmLockIMCC")); _ImmUnlockIMCC = reinterpret_cast<PIMMUNLOCKIMCC>(GetProcAddress(LibIME, "ImmUnlockIMC")); _ImmGetDefaultIMEWnd = reinterpret_cast<PIMMGETDEFAULTIMEWND>(GetProcAddress(LibIME, "ImmGetDefaultIMEWnd")); _ImmGetIMEFileName = reinterpret_cast<PIMMGETIMEFILENAME>(GetProcAddress(LibIME, "ImmGetIMEFileNameA")); _ImmNotifyIME = reinterpret_cast<PIMMNOTIFYIME>(GetProcAddress(LibIME, "ImmNotifyIME")); _ImmSetConversionStatus = reinterpret_cast<PIMMSETCONVERSIONSTATUS>( GetProcAddress(LibIME, "ImmSetConversionStatus")); _ImmSimulateHotKey = reinterpret_cast<PIMMSIMULATEHOTKEY>(GetProcAddress(LibIME, "ImmSimulateHotKey")); _ImmIsIME = reinterpret_cast<PIMMISIME>(GetProcAddress(LibIME, "ImmIsIME")); } // psapi.dll if (WindowsNT) LibPSAPI = LoadLibraryA("psapi.dll"); else LibPSAPI = nullptr; if (LibPSAPI) { _EmptyWorkingSet = reinterpret_cast<PEMPTYWORKINGSET>(GetProcAddress(LibPSAPI, "EmptyWorkingSet")); _InitializeProcessForWsWatch = reinterpret_cast<PINITIALIZEPROCESSFORWSWATCH>( GetProcAddress(LibPSAPI, "InitializeProcessForWsWatch")); _GetWsChanges = reinterpret_cast<PGETWSCHANGES>(GetProcAddress(LibPSAPI, "GetWsChanges")); _GetMappedFileName = reinterpret_cast<PGETMAPPEDFILENAMEA>(GetProcAddress(LibPSAPI, "GetMappedFileNameA")); } // ws2_32.dll if (Environment.NetworkGame || gEnableGosView) { LibWinSock = LoadLibraryA("ws2_32.dll"); if (LibWinSock == nullptr) LibWinSock = LoadLibraryA("wsock32.dll"); if (LibWinSock) { _accept = reinterpret_cast<PACCEPT>(GetProcAddress(LibWinSock, "accept")); _bind = reinterpret_cast<PBIND>(GetProcAddress(LibWinSock, "bind")); _closesocket = reinterpret_cast<PCLOSESOCKET>(GetProcAddress(LibWinSock, "closesocket")); _gethostbyname = reinterpret_cast<PGETHOSTBYNAME>(GetProcAddress(LibWinSock, "gethostbyname")); _gethostname = reinterpret_cast<PGETHOSTNAME>(GetProcAddress(LibWinSock, "gethostname")); _getservbyname = reinterpret_cast<PGETSERVBYNAME>(GetProcAddress(LibWinSock, "getservbyname")); _htonl = reinterpret_cast<PHTONL>(GetProcAddress(LibWinSock, "htonl")); _htons = reinterpret_cast<PHTONS>(GetProcAddress(LibWinSock, "htons")); _inet_addr = reinterpret_cast<PINET_ADDR>(GetProcAddress(LibWinSock, "inet_addr")); _listen = reinterpret_cast<PLISTEN>(GetProcAddress(LibWinSock, "listen")); _ntohl = reinterpret_cast<PNTOHL>(GetProcAddress(LibWinSock, "ntohl")); _recv = reinterpret_cast<PRECV>(GetProcAddress(LibWinSock, "recv")); _recvfrom = reinterpret_cast<PRECVFROM>(GetProcAddress(LibWinSock, "recvfrom")); _send = reinterpret_cast<PSEND>(GetProcAddress(LibWinSock, "send")); _sendto = reinterpret_cast<PSENDTO>(GetProcAddress(LibWinSock, "sendto")); _socket = reinterpret_cast<PSOCKET>(GetProcAddress(LibWinSock, "socket")); _WSACleanup = reinterpret_cast<PWSACLEANUP>(GetProcAddress(LibWinSock, "WSACleanup")); _WSAGetLastError = reinterpret_cast<PWSAGETLASTERROR>(GetProcAddress(LibWinSock, "WSAGetLastError")); _WSAStartup = reinterpret_cast<PWSASTARTUP>(GetProcAddress(LibWinSock, "WSAStartup")); } } // amstream.dll quartz.dll msadp32.acm LibAmstream = LoadLibraryA("amstream.dll"); LibQuartz = LoadLibraryA("quartz.dll"); LibMSADP32 = LoadLibraryA("msadp32.acm"); if ((LibAmstream == nullptr) || (LibQuartz == nullptr)) { // pszMessage = gos_GetResourceString(gLanguageDLL, 10040u); pszMessage = "DirectX Media not installed"; MessageBoxA(nullptr, pszMessage, ApplicationName, MB_ICONEXCLAMATION); status = AfterExit; _exit(EXIT_FAILURE); } if (LibMSADP32 == nullptr) { // pszMessage = gos_GetResourceString(gLanguageDLL, 10042Au); pszMessage = "Microsoft audio compression not installed"; MessageBoxA(nullptr, pszMessage, ApplicationName, MB_ICONEXCLAMATION); status = AfterExit; _exit(EXIT_FAILURE); } // NOTE: useless code => meant to be moved up? if (LibAmstream == nullptr) { nBufferSize = strlen("amstream.dll - Version 6.01"); pszMessage = GetDLLInfo("amstream.dll", 0); if (strncmp(pszMessage, "amstream.dll - Version 6.01", nBufferSize) < 0) { // pszMessage = gos_GetResourceString(gLanguageDLL, 10043u); pszMessage = "Please install DirectX Media 6.0 or later"; MessageBoxA(nullptr, pszMessage, ApplicationName, MB_ICONEXCLAMATION); status = AfterExit; _exit(EXIT_FAILURE); } } _AMGetErrorText = reinterpret_cast<PAMGETERRORTEXTA>(GetProcAddress(LibQuartz, "AMGetErrorTextA")); if (_AMGetErrorText == nullptr) { pszMessage = "Cannot find DirectShow functions"; MessageBoxA(nullptr, pszMessage, ApplicationName, MB_ICONEXCLAMATION); status = AfterExit; _exit(EXIT_FAILURE); } #if _CONSIDERED_OBSOLETE // Windows 9X vmcpd.vxd VersionInformation.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); GetVersionExA(&VersionInformation); if (WindowsNT == false) { if (HasKatmai) { if (LOWORD(VersionInformation.dwBuildNumber) == 1998) { GetSystemDirectoryA(szDirBuffer, MAX_PATH); strcat(szDirBuffer, "\\vmm32\\vmcpd.vxd"); if (gos_DoesFileExist(szDirBuffer) == false) { strcpy_s(szInstallMessage, _countof(szInstallMessage), "You need to install \"vmcpd.vxd\" This can be found " "in DirectX 7.0 SDK \"DXF\\extras\\win98 piii dbg\" " "folder."); if (OnNetwork == true) strcat_s(szInstallMessage, _countof(szInstallMessage), "\n\n(Microsoft Internal) - This can be found at " "\\\\dxrelease\\release\\dx7\\DXF\\extras\\win98 " "piii dbg"); MessageBoxA(nullptr, szInstallMessage, ApplicationName, MB_ICONEXCLAMATION); } } } } #endif // odbc32.dll LibODBC = LoadLibraryA("odbc32.dll"); if (LibODBC) { _SQLAllocHandle = reinterpret_cast<PSQLALLOCHANDLE>(GetProcAddress(LibODBC, "SQLAllocHandle")); _SQLBindCol = reinterpret_cast<PSQLBINDCOL>(GetProcAddress(LibODBC, "SQLBindCol")); _SQLBindParameter = reinterpret_cast<PSQLBINDPARAMETER>(GetProcAddress(LibODBC, "SQLBindParameter")); _SQLDisconnect = reinterpret_cast<PSQLDISCONNECT>(GetProcAddress(LibODBC, "SQLDisconnect")); _SQLDriverConnect = reinterpret_cast<PSQLDRIVERCONNECT>(GetProcAddress(LibODBC, "SQLDriverConnect")); _SQLExecDirect = reinterpret_cast<PSQLEXECDIRECT>(GetProcAddress(LibODBC, "SQLExecDirect")); _SQLFetch = reinterpret_cast<PSQLFETCH>(GetProcAddress(LibODBC, "SQLFetch")); _SQLFreeHandle = reinterpret_cast<PSQLFREEHANDLE>(GetProcAddress(LibODBC, "SQLFreeHandle")); _SQLFreeStmt = reinterpret_cast<PSQLFREESTMT>(GetProcAddress(LibODBC, "SQLFreeStmt")); _SQLGetDiagField = reinterpret_cast<PSQLGETDIAGFIELD>(GetProcAddress(LibODBC, "SQLGetDiagField")); _SQLGetDiagRec = reinterpret_cast<PSQLGETDIAGREC>(GetProcAddress(LibODBC, "SQLGetDiagRec")); _SQLNumResultCols = reinterpret_cast<PSQLNUMRESULTCOLS>(GetProcAddress(LibODBC, "SQLNumResultCols")); _SQLSetEnvAttr = reinterpret_cast<PSQLSETENVATTR>(GetProcAddress(LibODBC, "SQLSetEnvAttr")); } gos_MathExceptions(true, false); }
CSystemInfo::CSystemInfo() { GetDirectXVersion(); }
static VOID InitializeSystemPage(HWND hwndDlg) { WCHAR szTime[200]; WCHAR szOSName[50]; DWORD Length; DWORDLONG AvailableBytes, UsedBytes; MEMORYSTATUSEX mem; WCHAR szFormat[40]; WCHAR szDesc[50]; SYSTEM_INFO SysInfo; OSVERSIONINFO VersionInfo; /* set date/time */ szTime[0] = L'\0'; Length = GetDateFormat(LOCALE_SYSTEM_DEFAULT, DATE_LONGDATE, NULL, NULL, szTime, sizeof(szTime) / sizeof(WCHAR)); if (Length) { szTime[Length-1] = L','; szTime[Length++] = L' '; } Length = GetTimeFormatW(LOCALE_SYSTEM_DEFAULT, TIME_FORCE24HOURFORMAT|LOCALE_NOUSEROVERRIDE, NULL, NULL, &szTime[Length], (sizeof(szTime) / sizeof(WCHAR))); szTime[199] = L'\0'; SendDlgItemMessageW(hwndDlg, IDC_STATIC_TIME, WM_SETTEXT, 0, (LPARAM)szTime); /* set computer name */ szTime[0] = L'\0'; Length = sizeof(szTime) / sizeof(WCHAR); if (GetComputerNameW(szTime, &Length)) SendDlgItemMessageW(hwndDlg, IDC_STATIC_COMPUTER, WM_SETTEXT, 0, (LPARAM)szTime); /* set product name */ if (GetRegValue(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", L"ProductName", REG_SZ, szOSName, sizeof(szOSName))) { if (LoadStringW(hInst, IDS_OS_VERSION, szFormat, sizeof(szFormat) / sizeof(WCHAR))) { WCHAR szCpuName[50]; ZeroMemory(&VersionInfo, sizeof(OSVERSIONINFO)); VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetSystemCPU(szCpuName); if (GetVersionEx(&VersionInfo)) { szTime[(sizeof(szTime) / sizeof(WCHAR))-1] = L'\0'; wsprintfW(szTime, szFormat, szOSName, szCpuName, VersionInfo.dwMajorVersion, VersionInfo.dwMinorVersion, VersionInfo.dwBuildNumber); SendDlgItemMessageW(hwndDlg, IDC_STATIC_OS, WM_SETTEXT, 0, (LPARAM)szTime); } else { /* If the version of the OS cannot be retrieved for some reason, then just give the OS Name and Architecture */ szTime[(sizeof(szTime) / sizeof(WCHAR))-1] = L'\0'; wsprintfW(szTime, L"%s %s", szOSName, szCpuName); SendDlgItemMessageW(hwndDlg, IDC_STATIC_OS, WM_SETTEXT, 0, (LPARAM)szTime); } } } else { if (LoadStringW(hInst, IDS_VERSION_UNKNOWN, szTime, sizeof(szTime) / sizeof(WCHAR))) { szTime[(sizeof(szTime) / sizeof(WCHAR))-1] = L'\0'; SendDlgItemMessage(hwndDlg, IDC_STATIC_VERSION, WM_SETTEXT, 0, (LPARAM)szTime); } } /* FIXME set product language/local language */ if (GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_SLANGUAGE , szTime, sizeof(szTime) / sizeof(WCHAR))) SendDlgItemMessageW(hwndDlg, IDC_STATIC_LANG, WM_SETTEXT, 0, (LPARAM)szTime); /* set system manufacturer */ szTime[0] = L'\0'; if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\BIOS", L"SystemManufacturer", REG_SZ, szTime, sizeof(szTime))) { szTime[199] = L'\0'; SendDlgItemMessageW(hwndDlg, IDC_STATIC_MANU, WM_SETTEXT, 0, (LPARAM)szTime); } /* set motherboard model */ szTime[0] = L'\0'; if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\BIOS", L"SystemProductName", REG_SZ, szTime, sizeof(szTime))) { SendDlgItemMessageW(hwndDlg, IDC_STATIC_MODEL, WM_SETTEXT, 0, (LPARAM)szTime); } /* set bios model */ szTime[0] = L'\0'; if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\BIOS", L"BIOSVendor", REG_SZ, szTime, sizeof(szTime))) { DWORD Index; DWORD StrLength = (sizeof(szTime) / sizeof(WCHAR)); Index = wcslen(szTime); StrLength -= Index; if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\BIOS", L"BIOSReleaseDate", REG_SZ, &szTime[Index], StrLength)) { if (Index + StrLength > (sizeof(szTime)/sizeof(WCHAR))- 15) { //FIXME retrieve BiosMajorRelease, BiosMinorRelease //StrLength = wcslen(&szTime[Index]); //szTime[Index+StrLength] = L' '; //wcscpy(&szTime[Index+StrLength], L"Ver: "); //FIXME NON-NLS //szTime[(sizeof(szTime)/sizeof(WCHAR))-1] = L'\0'; } SendDlgItemMessageW(hwndDlg, IDC_STATIC_BIOS, WM_SETTEXT, 0, (LPARAM)szTime); } } /* set processor string */ if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\CentralProcessor\\0", L"ProcessorNameString", REG_SZ, szDesc, sizeof(szDesc))) { /* FIXME retrieve current speed */ szFormat[0] = L'\0'; GetSystemInfo(&SysInfo); if (SysInfo.dwNumberOfProcessors > 1) LoadStringW(hInst, IDS_FORMAT_MPPROC, szFormat, sizeof(szFormat) / sizeof(WCHAR)); else LoadStringW(hInst, IDS_FORMAT_UNIPROC, szFormat, sizeof(szFormat) / sizeof(WCHAR)); szFormat[(sizeof(szFormat)/sizeof(WCHAR))-1] = L'\0'; wsprintfW(szTime, szFormat, szDesc, SysInfo.dwNumberOfProcessors); SendDlgItemMessageW(hwndDlg, IDC_STATIC_PROC, WM_SETTEXT, 0, (LPARAM)szTime); } /* retrieve available memory */ ZeroMemory(&mem, sizeof(mem)); mem.dwLength = sizeof(mem); if (GlobalMemoryStatusEx(&mem)) { if (LoadStringW(hInst, IDS_FORMAT_MB, szFormat, sizeof(szFormat) / sizeof(WCHAR))) { /* set total mem string */ szFormat[(sizeof(szFormat) / sizeof(WCHAR))-1] = L'\0'; wsprintfW(szTime, szFormat, (mem.ullTotalPhys/1048576)); SendDlgItemMessageW(hwndDlg, IDC_STATIC_MEM, WM_SETTEXT, 0, (LPARAM)szTime); } if (LoadStringW(hInst, IDS_FORMAT_SWAP, szFormat, sizeof(szFormat) / sizeof(WCHAR))) { /* set swap string */ AvailableBytes = (mem.ullTotalPageFile-mem.ullTotalPhys)/1048576; UsedBytes = (mem.ullTotalPageFile-mem.ullAvailPageFile)/1048576; szFormat[(sizeof(szFormat) / sizeof(WCHAR))-1] = L'\0'; wsprintfW(szTime, szFormat, (UsedBytes), (AvailableBytes)); SendDlgItemMessageW(hwndDlg, IDC_STATIC_SWAP, WM_SETTEXT, 0, (LPARAM)szTime); } } /* set directx version string */ wcscpy(szTime, L"ReactX "); if (GetDirectXVersion(&szTime[7])) { SendDlgItemMessage(hwndDlg, IDC_STATIC_VERSION, WM_SETTEXT, 0, (LPARAM)szTime); } else { if (LoadStringW(hInst, IDS_VERSION_UNKNOWN, szTime, sizeof(szTime) / sizeof(WCHAR))) { szTime[(sizeof(szTime) / sizeof(WCHAR))-1] = L'\0'; SendDlgItemMessage(hwndDlg, IDC_STATIC_VERSION, WM_SETTEXT, 0, (LPARAM)szTime); } } }
void MachineInfo::DescribeMachine() { GetPlatform(); GetCpuClass(); Print("+====================================================================+\n"); Print("| |\n"); char txt[256]; switch (platform) { case OS_WIN95: sprintf_s(txt, "Windows 95 version %d.%d.%d %s", //-V576 os_ver.dwMajorVersion, os_ver.dwMinorVersion, LOWORD(os_ver.dwBuildNumber), os_ver.szCSDVersion); break; case OS_WIN98: sprintf_s(txt, "Windows 98 version %d.%d.%d %s", //-V576 os_ver.dwMajorVersion, os_ver.dwMinorVersion, LOWORD(os_ver.dwBuildNumber), os_ver.szCSDVersion); break; case OS_WINNT: sprintf_s(txt, "Windows NT %d.%d (Build %d) %s", //-V576 os_ver.dwMajorVersion, os_ver.dwMinorVersion, os_ver.dwBuildNumber, os_ver.szCSDVersion); break; case OS_WIN2K: sprintf_s(txt, "Windows 2000 %d.%d (Build %d) %s", //-V576 os_ver.dwMajorVersion, os_ver.dwMinorVersion, os_ver.dwBuildNumber, os_ver.szCSDVersion); case OS_WINXP: sprintf_s(txt, "Windows XP %d.%d (Build %d) %s", //-V576 os_ver.dwMajorVersion, os_ver.dwMinorVersion, os_ver.dwBuildNumber, os_ver.szCSDVersion); break; case OS_WINXP64: sprintf_s(txt, "Windows XP x64 %d.%d (Build %d) %s", //-V576 os_ver.dwMajorVersion, os_ver.dwMinorVersion, os_ver.dwBuildNumber, os_ver.szCSDVersion); break; case OS_WINVISTA: sprintf_s(txt, "Windows Vista %d.%d (Build %d) %s", //-V576 os_ver.dwMajorVersion, os_ver.dwMinorVersion, os_ver.dwBuildNumber, os_ver.szCSDVersion); break; case OS_WINSEVEN: sprintf_s(txt, "Windows 7 %d.%d (Build %d) %s", //-V576 os_ver.dwMajorVersion, os_ver.dwMinorVersion, os_ver.dwBuildNumber, os_ver.szCSDVersion); break; case OS_WINFUTURE: sprintf_s(txt, "Windows from the future %d.%d (Build %d) %s", //-V576 os_ver.dwMajorVersion, os_ver.dwMinorVersion, os_ver.dwBuildNumber, os_ver.szCSDVersion); break; default: sprintf_s(txt, "Unknown Operating System Platform"); break; } Print("| %-66s |\n", txt); Print("| |\n"); if (platform == OS_WIN95 || platform == OS_WIN98) DescribeOwner95(); else DescribeOwnerNT(); sprintf_s(txt, "CPUs Detected: %d CPU Level: %d.%d.%d CPU Speed: %d", //-V576 cpu_info.dwNumberOfProcessors, cpu_info.wProcessorLevel, cpu_info.wProcessorRevision >> 8, cpu_info.wProcessorRevision & 0xff, GetCpuSpeed() + 1); Print("| %-66s |\n", txt); DescribeCpuMake(); GlobalMemoryStatus(&mem_info); total_ram = (int) (mem_info.dwTotalPhys/(1024*1024)) + 1; int swap_max = (int) (mem_info.dwTotalPageFile/(1024*1024)); int swap_avail = (int) (mem_info.dwAvailPageFile/(1024*1024)); sprintf_s(txt, "%d MB RAM %d MB Max Swap %d MB Avail Swap", total_ram, swap_max, swap_avail); Print("| %-66s |\n", txt); Print("| |\n"); Print("| DirectX %d installed. |\n", GetDirectXVersion()); DescribeDXVersion("DDRAW"); DescribeDXVersion("D3DIM"); DescribeDXVersion("DINPUT"); DescribeDXVersion("DPLAY"); DescribeDXVersion("DSOUND"); DescribeDXVersion("DMUSIC"); DescribeDXVersion("DSHOW"); Print("| |\n"); if (platform == OS_WIN95 || platform == OS_WIN98) { DescribeDrivers95("Display"); DescribeDrivers95("Media"); DescribeDrivers95("Monitor"); DescribeDrivers95("Multimedia"); } else { DescribeDriversNT(""); } Print("+====================================================================+\n"); Print("\n"); }