Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4862 lines
172 KiB

  1. /****************************************************************************
  2. *
  3. * File: main.cpp
  4. * Project: DxDiag (DirectX Diagnostic Tool)
  5. * Author: Mike Anderson (manders@microsoft.com)
  6. * Purpose: Main file for DxDiag.
  7. *
  8. * (C) Copyright 1998 Microsoft Corp. All rights reserved.
  9. *
  10. * DxDiag Command-line options:
  11. * <none> : Run with graphical user interface
  12. * -ghost : Show Ghost Display Devices option (this flag must come next)
  13. * -saveonly : GUI, just choose where to save text file, save, then exit
  14. * -d : No GUI, generate comma-separated-values (csv) file
  15. * -p : No GUI, generate text file named dxdiag.txt
  16. * <path> : No GUI, generate text file named <path>
  17. *
  18. ****************************************************************************/
  19. #define STRICT
  20. #include <tchar.h>
  21. #include <Windows.h>
  22. #include <basetsd.h>
  23. #include <process.h>
  24. #include <commctrl.h>
  25. #include <richedit.h>
  26. #include <commdlg.h>
  27. #include <stdio.h>
  28. #include <shellapi.h>
  29. #include <mmsystem.h>
  30. #include <wbemidl.h>
  31. #include <objbase.h>
  32. #include <d3d.h>
  33. #include <dsound.h>
  34. #include <dmerror.h>
  35. #include <dplay.h>
  36. #include <shlobj.h>
  37. #include <shfolder.h>
  38. #include "resource.h"
  39. #include "reginfo.h"
  40. #include "sysinfo.h"
  41. #include "fileinfo.h"
  42. #include "dispinfo.h"
  43. #include "sndinfo.h"
  44. #include "musinfo.h"
  45. #include "showinfo.h"
  46. #include "inptinfo.h"
  47. #include "netinfo.h"
  48. #include "testdd.h"
  49. #include "testagp.h"
  50. #include "testd3d8.h"
  51. #include "testsnd.h"
  52. #include "testmus.h"
  53. #include "testnet.h"
  54. #include "save.h"
  55. #include "ghost.h"
  56. #define WM_COMMAND_REAL (WM_APP+2)
  57. #define WM_QUERYSKIP (WM_APP+3)
  58. #define WM_QUERYSKIP_REAL (WM_APP+4)
  59. #define WM_NETMEETINGWARN (WM_APP+5)
  60. #define WM_NETMEETINGWARN_REAL (WM_APP+6)
  61. #define WM_REPORTERROR (WM_APP+7)
  62. #define WM_REPORTERROR_REAL (WM_APP+8)
  63. #define WM_APP_PROGRESS (WM_APP+10)
  64. struct UI_MSG_NODE
  65. {
  66. UINT message;
  67. WPARAM wparam;
  68. LPARAM lparam;
  69. UI_MSG_NODE* pNext;
  70. };
  71. struct DXFILE_SORT_INFO
  72. {
  73. LONG nSortDirection;
  74. DWORD dwColumnToSort;
  75. };
  76. // This is the only global function in this file:
  77. BOOL BTranslateError(HRESULT hr, TCHAR* psz, BOOL bEnglish = FALSE);
  78. static BOOL OldWindowsVersion(VOID);
  79. static VOID ReportError(LONG idsDescription, HRESULT hr = S_OK);
  80. static VOID ReportErrorReal(LONG idsDescription, HRESULT hr);
  81. static INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  82. static INT_PTR CALLBACK PageDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  83. static HRESULT CreateTabs(HWND hwndTabs);
  84. static HRESULT CleanupPage(HWND hwndTabs, INT iPage);
  85. static HRESULT SetupPage(HWND hwndTabs, INT iPage);
  86. static HRESULT SetupHelpPage(HWND hwndTabs);
  87. static VOID ShowBullets(VOID);
  88. static VOID HideBullets(VOID);
  89. static HRESULT SetupDxFilesPage(VOID);
  90. static HRESULT SetupDisplayPage(LONG iDisplay);
  91. static HRESULT SetupSoundPage(LONG iSound);
  92. static HRESULT SetupMusicPage(VOID);
  93. static HRESULT SetupInputPage(VOID);
  94. static HRESULT SetupInputDevices9x(VOID);
  95. static HRESULT SetupInputDevicesNT(VOID);
  96. static HRESULT SetupNetworkPage(VOID);
  97. static HRESULT SetupStillStuckPage(VOID);
  98. static HRESULT CreateFileInfoColumns(HWND hwndList, BOOL bDrivers);
  99. static HRESULT CreateMusicColumns(HWND hwndList);
  100. static HRESULT AddFileInfo(HWND hwndList, FileInfo* pFileInfoFirst, BOOL bDrivers = FALSE);
  101. static HRESULT AddMusicPortInfo(HWND hwndList, MusicInfo* pMusicInfo);
  102. static HRESULT ScanSystem(VOID);
  103. static VOID SaveInfo(VOID);
  104. static VOID ToggleDDAccel(VOID);
  105. static VOID ToggleD3DAccel(VOID);
  106. static VOID ToggleAGPSupport(VOID);
  107. static VOID ToggleDMAccel(VOID);
  108. static VOID SaveAndSendBug(TCHAR* szPath);
  109. static VOID OverrideDDRefresh(VOID);
  110. static INT_PTR CALLBACK OverrideRefreshDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  111. static VOID ShowHelp(VOID);
  112. static VOID RestoreDrivers(VOID);
  113. static BOOL BCanRestoreDrivers(VOID);
  114. static VOID HandleSndSliderChange(INT nScrollCode, INT nPos);
  115. static VOID TroubleShoot( BOOL bTroubleShootSound );
  116. static BOOL QueryCrashProtection( TCHAR* strKey, TCHAR* strValue, int nSkipQuestionID, DWORD dwCurrentStep );
  117. static VOID EnterCrashProtection( TCHAR* strKey, TCHAR* strValue, DWORD dwCurrentStep );
  118. static VOID LeaveCrashProtection( TCHAR* strKey, TCHAR* strValue, DWORD dwCurrentStep );
  119. static VOID TestD3D(HWND hwndMain, DisplayInfo* pDisplayInfo);
  120. static BOOL GetTxtPath( TCHAR* strTxtPath );
  121. static VOID SetTxtPath( TCHAR* strTxtPath );
  122. static UINT WINAPI UIThreadProc( LPVOID lpParameter );
  123. static BOOL s_bGUI = FALSE;
  124. static BOOL s_bGhost = FALSE;
  125. static BOOL s_bSaveOnly = FALSE;
  126. static HWND s_hwndMain = NULL;
  127. static HWND s_hwndCurPage = NULL;
  128. static HHOOK s_hHook = NULL;
  129. static LONG s_lwCurPage = -1;
  130. static LONG s_iPageDisplayFirst = -1;
  131. static LONG s_iPageSoundFirst = -1;
  132. static LONG s_iPageMusic = -1;
  133. static LONG s_iPageInput = -1;
  134. static LONG s_iPageNetwork = -1;
  135. static LONG s_iPageStillStuck = -1;
  136. static HIMAGELIST s_himgList = NULL;
  137. static SysInfo s_sysInfo;
  138. static FileInfo* s_pDxWinComponentsFileInfoFirst = NULL;
  139. static FileInfo* s_pDxComponentsFileInfoFirst = NULL;
  140. static DisplayInfo* s_pDisplayInfoFirst = NULL;
  141. static LONG s_numDisplayInfo = 0;
  142. static SoundInfo* s_pSoundInfoFirst = NULL;
  143. static LONG s_numSoundInfo = 0;
  144. static MusicInfo* s_pMusicInfo = NULL;
  145. static InputInfo* s_pInputInfo = NULL;
  146. static NetInfo* s_pNetInfo = NULL;
  147. static ShowInfo* s_pShowInfo = NULL;
  148. static CRITICAL_SECTION s_cs;
  149. static DWORD s_dwMainThreadID = 0;
  150. static HANDLE s_hUIThread = NULL;
  151. static HANDLE s_hQuerySkipEvent = NULL;
  152. static DWORD s_nSkipComponent = 0;
  153. static BOOL s_bQuerySkipAllow = FALSE;
  154. static UI_MSG_NODE* s_pUIMsgHead = NULL;
  155. static HANDLE s_hUIMsgEvent = NULL;
  156. static BOOL s_bScanDone = FALSE;
  157. static DXFILE_SORT_INFO s_sortInfo;
  158. static HINSTANCE g_hInst = NULL;
  159. static BOOL s_bUseSystemInfo = TRUE;
  160. static BOOL s_bUseDisplay = TRUE;
  161. static BOOL s_bUseDSound = TRUE;
  162. static BOOL s_bUseDMusic = TRUE;
  163. static BOOL s_bUseDInput = TRUE;
  164. static BOOL s_bUseDPlay = TRUE;
  165. static BOOL s_bUseDShow = TRUE;
  166. class CWMIHelper
  167. {
  168. public:
  169. CWMIHelper();
  170. ~CWMIHelper();
  171. };
  172. CWMIHelper g_WMIHelper;
  173. IWbemServices* g_pIWbemServices;
  174. /****************************************************************************
  175. *
  176. * WinMain - Entry point for DxDiag program
  177. *
  178. * Command-line options:
  179. * <none> : Run with graphical user interface
  180. * -ghost : Show Ghost Display Devices option (this flag must come next)
  181. * -saveonly : GUI, just choose where to save text file, save, then exit
  182. * -l : No GUI, generate shortcut to DxDiag, then exit
  183. * -d : No GUI, generate comma-separated-values (csv) file
  184. * -p : No GUI, generate text file named dxdiag.txt
  185. * <path> : No GUI, generate text file named <path>
  186. *
  187. ****************************************************************************/
  188. INT WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance,
  189. LPSTR lpCmdLine, INT nCmdShow)
  190. {
  191. HRESULT hr;
  192. HINSTANCE hinstRichEdit = NULL;
  193. g_hInst = hinstance;
  194. s_hQuerySkipEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
  195. s_hUIMsgEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
  196. InitializeCriticalSection( &s_cs );
  197. #ifdef UNICODE
  198. if (!BIsPlatformNT())
  199. {
  200. // Unicode version only runs on WinNT.
  201. // Can't use ReportError because it calls Unicode APIs
  202. CHAR szDescription[MAX_PATH];
  203. CHAR szMessage[MAX_PATH];
  204. CHAR szFmt2[MAX_PATH];
  205. CHAR szTitle[MAX_PATH];
  206. LoadStringA(NULL, IDS_UNICODEREQUIRESNT, szDescription, MAX_PATH);
  207. LoadStringA(NULL, IDS_ERRORFMT2, szFmt2, MAX_PATH);
  208. LoadStringA(NULL, IDS_ERRORTITLE, szTitle, MAX_PATH);
  209. wsprintfA(szMessage, szFmt2, szDescription);
  210. MessageBoxA(s_hwndMain, szMessage, szTitle, MB_OK);
  211. return 1;
  212. }
  213. #endif
  214. TCHAR* pszCmdLine = GetCommandLine();
  215. if( pszCmdLine )
  216. {
  217. // Skip past program name (first token in command line).
  218. if (*pszCmdLine == TEXT('"')) // Check for and handle quoted program name
  219. {
  220. pszCmdLine++;
  221. // Scan, and skip over, subsequent characters until another
  222. // double-quote or a null is encountered
  223. while (*pszCmdLine && (*pszCmdLine != TEXT('"')))
  224. pszCmdLine++;
  225. // If we stopped on a double-quote (usual case), skip over it.
  226. if (*pszCmdLine == TEXT('"'))
  227. pszCmdLine++;
  228. }
  229. else // First token wasn't a quote
  230. {
  231. while (*pszCmdLine > TEXT(' '))
  232. pszCmdLine++;
  233. }
  234. // Skip past any white space preceeding the second token.
  235. while (*pszCmdLine && (*pszCmdLine <= TEXT(' ')))
  236. pszCmdLine++;
  237. // Check for ghost flag (which must appear before any
  238. // other flags except -media due to this implementation)
  239. if (_tcsstr(pszCmdLine, TEXT("-ghost")) != NULL)
  240. {
  241. s_bGhost = TRUE;
  242. pszCmdLine += lstrlen(TEXT("-ghost"));
  243. // Skip past any white space
  244. while (*pszCmdLine && (*pszCmdLine <= TEXT(' ')))
  245. pszCmdLine++;
  246. }
  247. // Check command line to determine whether to run in GUI mode
  248. if (lstrcmp(pszCmdLine, TEXT("")) == 0)
  249. s_bGUI = TRUE;
  250. if (lstrcmp(pszCmdLine, TEXT("-saveonly")) == 0)
  251. {
  252. s_bGUI = TRUE;
  253. s_bSaveOnly = TRUE;
  254. }
  255. }
  256. // Check for pre-Win95 or pre-NT5
  257. if (OldWindowsVersion())
  258. {
  259. ReportError(IDS_OLDWINDOWSVERSION);
  260. return 1;
  261. }
  262. if (s_bSaveOnly)
  263. {
  264. // Save a text file using GUI and exit
  265. // ******* GetSystemInfo (SI:1) ********
  266. if( s_bUseSystemInfo )
  267. {
  268. s_bUseSystemInfo = QueryCrashProtection( DXD_IN_SI_KEY, DXD_IN_SI_VALUE, IDS_SI, 1 );
  269. if( s_bUseSystemInfo )
  270. {
  271. EnterCrashProtection( DXD_IN_SI_KEY, DXD_IN_SI_VALUE, 1 );
  272. GetSystemInfo(&s_sysInfo);
  273. LeaveCrashProtection( DXD_IN_SI_KEY, DXD_IN_SI_VALUE, 1 );
  274. }
  275. }
  276. // ******* GetBasicDisplayInfo (DD:1) ********
  277. if( s_bUseDisplay )
  278. {
  279. s_bUseDisplay = QueryCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, IDS_DD, 1 );
  280. if( s_bUseDisplay )
  281. {
  282. EnterCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 1 );
  283. if (FAILED(hr = GetBasicDisplayInfo(&s_pDisplayInfoFirst)))
  284. ReportError(IDS_NOBASICDISPLAYINFO, hr);
  285. LeaveCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 1 );
  286. }
  287. }
  288. // ******* GetBasicSoundInfo (DS:1) ********
  289. if( s_bUseDSound )
  290. {
  291. s_bUseDSound = QueryCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, IDS_DS, 1 );
  292. if( s_bUseDSound )
  293. {
  294. EnterCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 1 );
  295. if (FAILED(hr = GetBasicSoundInfo(&s_pSoundInfoFirst)))
  296. ReportError(IDS_NOBASICSOUNDINFO, hr); // (but keep running)
  297. LeaveCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 1 );
  298. }
  299. }
  300. // ******* GetBasicMusicInfo (DM:1) ********
  301. if( s_bUseDMusic )
  302. {
  303. s_bUseDMusic = QueryCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, IDS_DM, 1 );
  304. if( s_bUseDMusic )
  305. {
  306. EnterCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, 1 );
  307. if (FAILED(hr = GetBasicMusicInfo(&s_pMusicInfo)))
  308. ReportError(IDS_NOBASICMUSICINFO, hr); // (but keep running)
  309. LeaveCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, 1 );
  310. }
  311. }
  312. // ******* ScanSystem ********
  313. ScanSystem();
  314. SaveInfo();
  315. TCHAR szTitle[MAX_PATH];
  316. TCHAR szMessage[MAX_PATH];
  317. LoadString(NULL, IDS_APPFULLNAME, szTitle, MAX_PATH);
  318. LoadString(NULL, IDS_SAVEDONE, szMessage, MAX_PATH);
  319. MessageBox(NULL, szMessage, szTitle, MB_OK);
  320. }
  321. else if (!s_bGUI)
  322. {
  323. // Save a text file with no GUI and exit
  324. TCHAR szPath[MAX_PATH];
  325. // ******* GetSystemInfo (SI:1) ********
  326. if( s_bUseSystemInfo )
  327. {
  328. s_bUseSystemInfo = QueryCrashProtection( DXD_IN_SI_KEY, DXD_IN_SI_VALUE, IDS_SI, 1 );
  329. if( s_bUseSystemInfo )
  330. {
  331. EnterCrashProtection( DXD_IN_SI_KEY, DXD_IN_SI_VALUE, 1 );
  332. GetSystemInfo(&s_sysInfo);
  333. LeaveCrashProtection( DXD_IN_SI_KEY, DXD_IN_SI_VALUE, 1 );
  334. }
  335. }
  336. // ******* GetBasicDisplayInfo (DD:1) ********
  337. if( s_bUseDisplay )
  338. {
  339. s_bUseDisplay = QueryCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, IDS_DD, 1 );
  340. if( s_bUseDisplay )
  341. {
  342. EnterCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 1 );
  343. if (FAILED(hr = GetBasicDisplayInfo(&s_pDisplayInfoFirst)))
  344. ReportError(IDS_NOBASICDISPLAYINFO, hr);
  345. LeaveCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 1 );
  346. }
  347. }
  348. // ******* GetBasicSoundInfo (DS:1) ********
  349. if( s_bUseDSound )
  350. {
  351. s_bUseDSound = QueryCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, IDS_DS, 1 );
  352. if( s_bUseDSound )
  353. {
  354. EnterCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 1 );
  355. if (FAILED(hr = GetBasicSoundInfo(&s_pSoundInfoFirst)))
  356. ReportError(IDS_NOBASICSOUNDINFO, hr); // (but keep running)
  357. LeaveCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 1 );
  358. }
  359. }
  360. // ******* GetBasicMusicInfo (DM:1) ********
  361. if( s_bUseDMusic )
  362. {
  363. s_bUseDMusic = QueryCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, IDS_DM, 1 );
  364. if( s_bUseDMusic )
  365. {
  366. EnterCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, 1 );
  367. if (FAILED(hr = GetBasicMusicInfo(&s_pMusicInfo)))
  368. ReportError(IDS_NOBASICMUSICINFO, hr); // (but keep running)
  369. LeaveCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, 1 );
  370. }
  371. }
  372. // ******* ScanSystem ********
  373. ScanSystem();
  374. if( pszCmdLine )
  375. {
  376. if (_tcsicmp(pszCmdLine, TEXT("-d")) == 0)
  377. {
  378. wsprintf(szPath, TEXT("%s_%02d%02d%d_%02d%02d_Config.csv"),
  379. s_sysInfo.m_szMachine, s_sysInfo.m_time.wMonth,
  380. s_sysInfo.m_time.wDay, s_sysInfo.m_time.wYear,
  381. s_sysInfo.m_time.wHour, s_sysInfo.m_time.wMinute);
  382. if (FAILED(hr = SaveAllInfoCsv(szPath, &s_sysInfo,
  383. s_pDxComponentsFileInfoFirst,
  384. s_pDisplayInfoFirst, s_pSoundInfoFirst, s_pInputInfo)))
  385. {
  386. ReportError(IDS_PROBLEMSAVING, hr);
  387. goto LCleanup;
  388. }
  389. }
  390. else
  391. {
  392. if (_tcsicmp(pszCmdLine, TEXT("-p")) == 0)
  393. lstrcpy(szPath, TEXT("DxDiag.txt"));
  394. else
  395. lstrcpyn(szPath, pszCmdLine, MAX_PATH);
  396. szPath[MAX_PATH-1] = 0;
  397. if (FAILED(hr = SaveAllInfo(szPath, &s_sysInfo,
  398. s_pDxWinComponentsFileInfoFirst, s_pDxComponentsFileInfoFirst,
  399. s_pDisplayInfoFirst, s_pSoundInfoFirst, s_pMusicInfo,
  400. s_pInputInfo, s_pNetInfo, s_pShowInfo )))
  401. {
  402. ReportError(IDS_PROBLEMSAVING, hr);
  403. goto LCleanup;
  404. }
  405. }
  406. }
  407. }
  408. else
  409. {
  410. // Do full Windows GUI
  411. UINT dwUIThreadID;
  412. s_dwMainThreadID = GetCurrentThreadId();
  413. // Do scanning that must be done before the main dialog comes up:
  414. // ******* GetSystemInfo (SI:1) ********
  415. if( s_bUseSystemInfo )
  416. {
  417. s_bUseSystemInfo = QueryCrashProtection( DXD_IN_SI_KEY, DXD_IN_SI_VALUE, IDS_SI, 1 );
  418. if( s_bUseSystemInfo )
  419. {
  420. EnterCrashProtection( DXD_IN_SI_KEY, DXD_IN_SI_VALUE, 1 );
  421. GetSystemInfo(&s_sysInfo);
  422. LeaveCrashProtection( DXD_IN_SI_KEY, DXD_IN_SI_VALUE, 1 );
  423. }
  424. }
  425. // ******* GetBasicDisplayInfo (DD:1) ********
  426. if( s_bUseDisplay )
  427. {
  428. s_bUseDisplay = QueryCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, IDS_DD, 1 );
  429. if( s_bUseDisplay )
  430. {
  431. EnterCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 1 );
  432. if (FAILED(hr = GetBasicDisplayInfo(&s_pDisplayInfoFirst)))
  433. ReportError(IDS_NOBASICDISPLAYINFO, hr);
  434. LeaveCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 1 );
  435. }
  436. }
  437. // ******* GetBasicSoundInfo (DS:1) ********
  438. if( s_bUseDSound )
  439. {
  440. s_bUseDSound = QueryCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, IDS_DS, 1 );
  441. if( s_bUseDSound )
  442. {
  443. EnterCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 1 );
  444. if (FAILED(hr = GetBasicSoundInfo(&s_pSoundInfoFirst)))
  445. ReportError(IDS_NOBASICSOUNDINFO, hr); // (but keep running)
  446. LeaveCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 1 );
  447. }
  448. }
  449. // ******* GetBasicMusicInfo (DM:1) ********
  450. if( s_bUseDMusic )
  451. {
  452. s_bUseDMusic = QueryCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, IDS_DM, 1 );
  453. if( s_bUseDMusic )
  454. {
  455. EnterCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, 1 );
  456. if (FAILED(hr = GetBasicMusicInfo(&s_pMusicInfo)))
  457. ReportError(IDS_NOBASICMUSICINFO, hr); // (but keep running)
  458. LeaveCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, 1 );
  459. }
  460. }
  461. if( NULL == s_hUIThread )
  462. {
  463. // Create the UI thread
  464. s_hUIThread = (HANDLE) _beginthreadex( NULL, 0, UIThreadProc, NULL, 0, &dwUIThreadID );
  465. // Wait for either s_hwndMain is set or the UI thread to exit
  466. for(;;)
  467. {
  468. // Stop of the s_hwndMain is set
  469. if( s_hwndMain )
  470. break;
  471. // Stop if the UI thread is gone
  472. if( WAIT_TIMEOUT != WaitForSingleObject( s_hUIThread, 0 ) )
  473. break;
  474. Sleep(50);
  475. }
  476. }
  477. if( WAIT_TIMEOUT == WaitForSingleObject( s_hUIThread, 0 ) )
  478. {
  479. ScanSystem();
  480. s_bScanDone = TRUE;
  481. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  482. // Done scaning, so wait for the UI thread to exit
  483. WaitForSingleObject( s_hUIThread, INFINITE );
  484. }
  485. CloseHandle( s_hUIThread );
  486. }
  487. LCleanup:
  488. CloseHandle( s_hQuerySkipEvent );
  489. CloseHandle( s_hUIMsgEvent );
  490. DeleteCriticalSection( &s_cs );
  491. // Clean up:
  492. if (s_pDxComponentsFileInfoFirst != NULL)
  493. DestroyFileList(s_pDxComponentsFileInfoFirst);
  494. if (s_pDisplayInfoFirst != NULL)
  495. DestroyDisplayInfo(s_pDisplayInfoFirst);
  496. if (s_pSoundInfoFirst != NULL)
  497. DestroySoundInfo(s_pSoundInfoFirst);
  498. if (s_pMusicInfo != NULL)
  499. DestroyMusicInfo(s_pMusicInfo);
  500. if (s_pNetInfo != NULL)
  501. DestroyNetInfo(s_pNetInfo);
  502. if (s_pInputInfo != NULL)
  503. DestroyInputInfo(s_pInputInfo);
  504. if (s_pShowInfo != NULL)
  505. DestroyShowInfo(s_pShowInfo);
  506. ReleaseDigiSignData();
  507. return 0;
  508. }
  509. //-----------------------------------------------------------------------------
  510. // Name: UIThreadProc
  511. // Desc:
  512. //-----------------------------------------------------------------------------
  513. UINT WINAPI UIThreadProc( LPVOID lpParameter )
  514. {
  515. UNREFERENCED_PARAMETER( lpParameter );
  516. HICON hicon;
  517. HINSTANCE hinstRichEdit = NULL;
  518. HWND hMainDlg;
  519. MSG msg;
  520. hinstRichEdit = LoadLibrary(TEXT("RICHED20.DLL"));
  521. if (hinstRichEdit == NULL)
  522. {
  523. ReportError(IDS_NORICHED32);
  524. goto LCleanup;
  525. }
  526. InitCommonControls();
  527. s_himgList = ImageList_Create(16, 16, ILC_COLOR4 | ILC_MASK, 1, 0);
  528. if (s_himgList == NULL)
  529. {
  530. ReportError(IDS_NOIMAGELIST);
  531. goto LCleanup;
  532. }
  533. hicon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_CAUTION));
  534. if (hicon == NULL)
  535. {
  536. ReportError(IDS_NOICON);
  537. goto LCleanup;
  538. }
  539. ImageList_AddIcon(s_himgList, hicon);
  540. {
  541. // BUG 21632: Warn user if DirectX version is newer than DxDiag version
  542. // (Note: don't check down to the build number, just major.minor.revision)
  543. if( !BIsWinNT() )
  544. {
  545. DWORD dwMajorDX = 0, dwMinorDX = 0, dwRevisionDX = 0, dwBuildDX = 0;
  546. DWORD dwMajorDXD = 0, dwMinorDXD = 0, dwRevisionDXD = 0, dwBuildDXD = 0;
  547. if( _stscanf(s_sysInfo.m_szDirectXVersion, TEXT("%d.%d.%d.%d"), &dwMajorDX, &dwMinorDX, &dwRevisionDX, &dwBuildDX) != 4 )
  548. {
  549. dwMajorDX = 0;
  550. dwMinorDX = 0;
  551. dwRevisionDX = 0;
  552. dwBuildDX = 0;
  553. }
  554. if( _stscanf(s_sysInfo.m_szDxDiagVersion, TEXT("%d.%d.%d.%d"), &dwMajorDXD, &dwMinorDXD, &dwRevisionDXD, &dwBuildDXD) != 4 )
  555. {
  556. dwMajorDXD = 0;
  557. dwMinorDXD = 0;
  558. dwRevisionDXD = 0;
  559. dwBuildDXD = 0;
  560. }
  561. if (dwMajorDX > dwMajorDXD ||
  562. dwMajorDX == dwMajorDXD && dwMinorDX > dwMinorDXD ||
  563. dwMajorDX == dwMajorDXD && dwMinorDX == dwMinorDXD && dwRevisionDX > dwRevisionDXD)
  564. {
  565. TCHAR szFmt[MAX_PATH];
  566. TCHAR szMessage[MAX_PATH];
  567. TCHAR szTitle[MAX_PATH];
  568. LoadString(NULL, IDS_DXDIAGISOLDFMT, szFmt, MAX_PATH);
  569. wsprintf(szMessage, szFmt, s_sysInfo.m_szDirectXVersion, s_sysInfo.m_szDxDiagVersion);
  570. LoadString(NULL, IDS_APPFULLNAME, szTitle, MAX_PATH);
  571. MessageBox(NULL, szMessage, szTitle, MB_OK);
  572. }
  573. }
  574. }
  575. // Display the main dialog box.
  576. hMainDlg = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_MAINDIALOG),
  577. NULL, DialogProc );
  578. // Windows messages are available
  579. DWORD dwResult;
  580. BOOL bDone;
  581. bDone = FALSE;
  582. for(;;)
  583. {
  584. dwResult = MsgWaitForMultipleObjects( 1, &s_hUIMsgEvent, FALSE,
  585. INFINITE, QS_ALLEVENTS | QS_ALLINPUT | QS_ALLPOSTMESSAGE );
  586. switch( dwResult )
  587. {
  588. case WAIT_OBJECT_0:
  589. {
  590. if( s_pUIMsgHead )
  591. {
  592. UI_MSG_NODE* pCurNode = s_pUIMsgHead;
  593. UINT message = pCurNode->message;
  594. WPARAM wparam = pCurNode->wparam;
  595. LPARAM lparam = pCurNode->lparam;;
  596. s_pUIMsgHead = s_pUIMsgHead->pNext;
  597. delete pCurNode;
  598. if( s_pUIMsgHead )
  599. SetEvent( s_hUIMsgEvent );
  600. switch( message )
  601. {
  602. case WM_QUERYSKIP:
  603. message = WM_QUERYSKIP_REAL;
  604. break;
  605. case WM_NETMEETINGWARN:
  606. message = WM_NETMEETINGWARN_REAL;
  607. break;
  608. case WM_COMMAND:
  609. message = WM_COMMAND_REAL;
  610. break;
  611. case WM_REPORTERROR:
  612. message = WM_REPORTERROR_REAL;
  613. break;
  614. }
  615. SendMessage( hMainDlg, message, wparam, lparam );
  616. }
  617. break;
  618. }
  619. case WAIT_OBJECT_0 + 1:
  620. {
  621. while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
  622. {
  623. if( msg.message == WM_QUIT )
  624. bDone = TRUE;
  625. if( !IsDialogMessage( hMainDlg, &msg ) )
  626. {
  627. TranslateMessage( &msg );
  628. DispatchMessage( &msg );
  629. }
  630. }
  631. break;
  632. }
  633. }
  634. if( bDone )
  635. break;
  636. }
  637. DestroyWindow( hMainDlg );
  638. LCleanup:
  639. while( s_pUIMsgHead )
  640. {
  641. UI_MSG_NODE* pDelete = s_pUIMsgHead;
  642. s_pUIMsgHead = s_pUIMsgHead->pNext;
  643. delete pDelete;
  644. }
  645. // Clean up:
  646. if (s_himgList != NULL)
  647. ImageList_Destroy(s_himgList);
  648. if (hinstRichEdit != NULL)
  649. FreeLibrary(hinstRichEdit);
  650. return 0;
  651. }
  652. /****************************************************************************
  653. *
  654. * OldWindowsVersion - Returns TRUE if running NT before NT5 or pre-Win95.
  655. *
  656. ****************************************************************************/
  657. BOOL OldWindowsVersion(VOID)
  658. {
  659. OSVERSIONINFO OSVersionInfo;
  660. OSVersionInfo.dwOSVersionInfoSize = sizeof OSVersionInfo;
  661. GetVersionEx(&OSVersionInfo);
  662. if (OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
  663. {
  664. if (OSVersionInfo.dwMajorVersion == 4)
  665. {
  666. if (s_bSaveOnly)
  667. return FALSE; // NT4 supported if "-saveonly" specified
  668. // Ask if user wants to run in saveonly mode:
  669. TCHAR szTitle[MAX_PATH];
  670. TCHAR szMessage[MAX_PATH];
  671. LoadString(NULL, IDS_APPFULLNAME, szTitle, MAX_PATH);
  672. LoadString(NULL, IDS_NT4SAVEONLY, szMessage, MAX_PATH);
  673. if (IDYES == MessageBox(NULL, szMessage, szTitle, MB_YESNO))
  674. {
  675. s_bSaveOnly = TRUE;
  676. s_bGUI = TRUE;
  677. return FALSE;
  678. }
  679. }
  680. if (OSVersionInfo.dwMajorVersion < 5)
  681. return TRUE; // NT4 and earlier not supported
  682. }
  683. else
  684. {
  685. if (OSVersionInfo.dwMajorVersion < 4)
  686. return TRUE; // Pre-Win95 not supported
  687. }
  688. return FALSE; // Win95 or later, or NT5 or later
  689. }
  690. //-----------------------------------------------------------------------------
  691. // Name: ReportError
  692. // Desc:
  693. //-----------------------------------------------------------------------------
  694. VOID ReportError(LONG idsDescription, HRESULT hr)
  695. {
  696. if( s_hwndMain )
  697. PostMessage( s_hwndMain, WM_REPORTERROR, (WPARAM) idsDescription, (LPARAM) hr );
  698. else
  699. ReportErrorReal( idsDescription, hr );
  700. }
  701. //-----------------------------------------------------------------------------
  702. // Name: ReportErrorReal
  703. // Desc:
  704. //-----------------------------------------------------------------------------
  705. VOID ReportErrorReal(LONG idsDescription, HRESULT hr)
  706. {
  707. TCHAR szDescription[MAX_PATH];
  708. TCHAR szMessage[MAX_PATH];
  709. TCHAR szFmt1[MAX_PATH];
  710. TCHAR szFmt2[MAX_PATH];
  711. TCHAR szTitle[MAX_PATH];
  712. TCHAR szErrorDesc[MAX_PATH];
  713. LoadString(NULL, idsDescription, szDescription, MAX_PATH);
  714. LoadString(NULL, IDS_ERRORFMT1, szFmt1, MAX_PATH);
  715. LoadString(NULL, IDS_ERRORFMT2, szFmt2, MAX_PATH);
  716. LoadString(NULL, IDS_ERRORTITLE, szTitle, MAX_PATH);
  717. if (FAILED(hr))
  718. {
  719. BTranslateError(hr, szErrorDesc);
  720. wsprintf(szMessage, szFmt1, szDescription, hr, szErrorDesc);
  721. }
  722. else
  723. {
  724. wsprintf(szMessage, szFmt2, szDescription);
  725. }
  726. if (s_bGUI)
  727. MessageBox(s_hwndMain, szMessage, szTitle, MB_OK);
  728. else
  729. _tprintf(szMessage);
  730. }
  731. typedef BOOL (WINAPI* PfnCoSetProxyBlanket)(
  732. IUnknown *pProxy,
  733. DWORD dwAuthnSvc,
  734. DWORD dwAuthzSvc,
  735. OLECHAR *pServerPrincName,
  736. DWORD dwAuthnLevel,
  737. DWORD dwImpLevel,
  738. RPC_AUTH_IDENTITY_HANDLE pAuthInfo,
  739. DWORD dwCapabilities );
  740. /****************************************************************************
  741. *
  742. * CWMIHelper - Inits DCOM and g_pIWbemServices
  743. *
  744. ****************************************************************************/
  745. CWMIHelper::CWMIHelper(VOID)
  746. {
  747. HRESULT hr;
  748. IWbemLocator* pIWbemLocator = NULL;
  749. BSTR pNamespace = NULL;
  750. HINSTANCE hinstOle32 = NULL;
  751. CoInitialize( 0 );
  752. hr = CoCreateInstance( CLSID_WbemLocator,
  753. NULL,
  754. CLSCTX_INPROC_SERVER,
  755. IID_IWbemLocator,
  756. (LPVOID*) &pIWbemLocator);
  757. if( FAILED(hr) || pIWbemLocator == NULL )
  758. goto LCleanup;
  759. // Using the locator, connect to WMI in the given namespace.
  760. pNamespace = SysAllocString( L"\\\\.\\root\\cimv2" );
  761. hr = pIWbemLocator->ConnectServer( pNamespace, NULL, NULL, 0L,
  762. 0L, NULL, NULL, &g_pIWbemServices );
  763. if( FAILED(hr) || g_pIWbemServices == NULL )
  764. goto LCleanup;
  765. hinstOle32 = LoadLibrary( TEXT("ole32.dll") );
  766. if( hinstOle32 )
  767. {
  768. PfnCoSetProxyBlanket pfnCoSetProxyBlanket = NULL;
  769. pfnCoSetProxyBlanket = (PfnCoSetProxyBlanket)GetProcAddress( hinstOle32, "CoSetProxyBlanket" );
  770. if (pfnCoSetProxyBlanket != NULL)
  771. {
  772. // Switch security level to IMPERSONATE.
  773. pfnCoSetProxyBlanket( g_pIWbemServices, // proxy
  774. RPC_C_AUTHN_WINNT, // authentication service
  775. RPC_C_AUTHZ_NONE, // authorization service
  776. NULL, // server principle name
  777. RPC_C_AUTHN_LEVEL_CALL, // authentication level
  778. RPC_C_IMP_LEVEL_IMPERSONATE, // impersonation level
  779. NULL, // identity of the client
  780. EOAC_NONE ); // capability flags
  781. // If CoSetProxyBlanket, just leave it be and see if it works.
  782. }
  783. }
  784. LCleanup:
  785. if( hinstOle32 )
  786. FreeLibrary(hinstOle32);
  787. if(pNamespace)
  788. SysFreeString(pNamespace);
  789. if(pIWbemLocator)
  790. pIWbemLocator->Release();
  791. }
  792. /****************************************************************************
  793. *
  794. * ~CWMIHelper - Cleanup WMI
  795. *
  796. ****************************************************************************/
  797. CWMIHelper::~CWMIHelper(VOID)
  798. {
  799. if(g_pIWbemServices)
  800. g_pIWbemServices->Release();
  801. CoUninitialize();
  802. }
  803. /****************************************************************************
  804. *
  805. * DXFilesCompareFunc - Compares items on DirectX files pages
  806. *
  807. ****************************************************************************/
  808. int CALLBACK DXFilesCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lSortMethod)
  809. {
  810. FileInfo* pFileInfo1 = (FileInfo*) lParam1;
  811. FileInfo* pFileInfo2 = (FileInfo*) lParam2;
  812. switch( s_sortInfo.dwColumnToSort )
  813. {
  814. case 0:
  815. return (s_sortInfo.nSortDirection * (_tcscmp( pFileInfo1->m_szName,
  816. pFileInfo2->m_szName )));
  817. case 1:
  818. return (s_sortInfo.nSortDirection * (_tcscmp( pFileInfo1->m_szVersion,
  819. pFileInfo2->m_szVersion )));
  820. case 2:
  821. return (s_sortInfo.nSortDirection * (_tcscmp( pFileInfo1->m_szAttributes,
  822. pFileInfo2->m_szAttributes )));
  823. case 3:
  824. return (s_sortInfo.nSortDirection * (_tcscmp( pFileInfo1->m_szLanguageLocal,
  825. pFileInfo2->m_szLanguageLocal )));
  826. case 4:
  827. return ( s_sortInfo.nSortDirection * CompareFileTime( &pFileInfo1->m_FileTime,
  828. &pFileInfo2->m_FileTime ) );
  829. case 5:
  830. if( pFileInfo1->m_numBytes > pFileInfo2->m_numBytes )
  831. return (s_sortInfo.nSortDirection * 1);
  832. if( pFileInfo1->m_numBytes < pFileInfo2->m_numBytes )
  833. return (s_sortInfo.nSortDirection * -1);
  834. return 0;
  835. }
  836. return 0;
  837. }
  838. /****************************************************************************
  839. *
  840. * MsgHook
  841. *
  842. ****************************************************************************/
  843. LRESULT FAR PASCAL MsgHook(int nCode, WPARAM wParam, LPARAM lParam)
  844. {
  845. LPMSG pMsg = (LPMSG) lParam;
  846. if( pMsg &&
  847. pMsg->message == WM_KEYDOWN &&
  848. pMsg->wParam == VK_TAB &&
  849. GetKeyState(VK_CONTROL) < 0)
  850. {
  851. // Handle a ctrl-tab or ctrl-shift-tab
  852. if( GetKeyState(VK_SHIFT) < 0 )
  853. PostMessage( s_hwndMain, WM_COMMAND, IDC_PREV_TAB, 0 );
  854. else
  855. PostMessage( s_hwndMain, WM_COMMAND, IDC_NEXT_TAB, 0 );
  856. // Stop further processing, otherwise it will also be handled
  857. // as a plain tab key pressed by the internal IsDialogBox() call.
  858. pMsg->message = WM_NULL;
  859. pMsg->lParam = 0;
  860. pMsg->wParam = 0;
  861. }
  862. return CallNextHookEx( s_hHook, nCode, wParam, lParam);
  863. }
  864. /****************************************************************************
  865. *
  866. * DialogProc
  867. *
  868. ****************************************************************************/
  869. INT_PTR CALLBACK DialogProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
  870. {
  871. HWND hwndTabs = GetDlgItem(hwnd, IDC_TAB);
  872. switch (msg)
  873. {
  874. case WM_INITDIALOG:
  875. {
  876. SetForegroundWindow( hwnd );
  877. s_hwndMain = hwnd;
  878. s_hHook = SetWindowsHookEx( WH_GETMESSAGE, MsgHook,
  879. NULL, GetCurrentThreadId() );
  880. HINSTANCE hinst = (HINSTANCE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
  881. HICON hicon = LoadIcon(hinst, MAKEINTRESOURCE(IDI_APP));
  882. SendMessage(hwnd, WM_SETICON, TRUE, (LPARAM)hicon);
  883. SendMessage(hwnd, WM_SETICON, FALSE, (LPARAM)hicon);
  884. CreateTabs(hwndTabs);
  885. SetupPage(hwndTabs, 0);
  886. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  887. if( s_sysInfo.m_bNetMeetingRunning )
  888. PostMessage( s_hwndMain, WM_NETMEETINGWARN, 0, 0 );
  889. s_sortInfo.nSortDirection = 1;
  890. s_sortInfo.dwColumnToSort = -1;
  891. }
  892. return TRUE;
  893. case WM_APP_PROGRESS:
  894. {
  895. if( s_lwCurPage == 0 )
  896. {
  897. HWND hProgress = GetDlgItem( s_hwndCurPage, IDC_LOAD_PROGRESS );
  898. if( !s_bScanDone )
  899. {
  900. ShowWindow( hProgress, SW_SHOW );
  901. SendMessage( hProgress, PBM_DELTAPOS, 10, 0 );
  902. UpdateWindow( s_hwndMain );
  903. UpdateWindow( s_hwndCurPage );
  904. }
  905. else
  906. {
  907. ShowWindow( hProgress, SW_HIDE );
  908. EnableWindow( GetDlgItem(hwnd, IDNEXT), TRUE );
  909. EnableWindow( GetDlgItem(hwnd, IDSAVE), TRUE );
  910. }
  911. }
  912. }
  913. break;
  914. case WM_REPORTERROR:
  915. case WM_NETMEETINGWARN:
  916. case WM_COMMAND:
  917. case WM_QUERYSKIP:
  918. {
  919. UI_MSG_NODE* pMsg = new UI_MSG_NODE;
  920. if( NULL == pMsg )
  921. return TRUE;
  922. ZeroMemory( pMsg, sizeof(UI_MSG_NODE) );
  923. pMsg->message = msg;
  924. pMsg->lparam = lparam;
  925. pMsg->wparam = wparam;
  926. UI_MSG_NODE* pEnum = s_pUIMsgHead;
  927. UI_MSG_NODE* pPrev = NULL;
  928. while( pEnum )
  929. {
  930. pPrev = pEnum;
  931. pEnum = pEnum->pNext;
  932. }
  933. if( pPrev )
  934. pPrev->pNext = pMsg;
  935. else
  936. s_pUIMsgHead = pMsg;
  937. SetEvent( s_hUIMsgEvent );
  938. return TRUE;
  939. }
  940. case WM_REPORTERROR_REAL:
  941. {
  942. ReportErrorReal( (LONG) wparam, (HRESULT) lparam );
  943. return TRUE;
  944. }
  945. case WM_NETMEETINGWARN_REAL:
  946. {
  947. TCHAR strMessage[MAX_PATH];
  948. TCHAR strTitle[MAX_PATH];
  949. LoadString(NULL, IDS_APPFULLNAME, strTitle, MAX_PATH);
  950. LoadString(NULL, IDS_NETMEETINGWARN, strMessage, MAX_PATH);
  951. MessageBox( s_hwndMain, strMessage, strTitle, MB_OK|MB_ICONWARNING );
  952. return TRUE;
  953. }
  954. case WM_QUERYSKIP_REAL:
  955. {
  956. EnableWindow( s_hwndMain, FALSE );
  957. TCHAR szTitle[MAX_PATH];
  958. TCHAR szMessage[MAX_PATH];
  959. TCHAR szFmt[MAX_PATH];
  960. TCHAR szMessageComponent[MAX_PATH];
  961. LoadString(0, IDS_APPFULLNAME, szTitle, MAX_PATH);
  962. LoadString(0, IDS_SKIP, szFmt, MAX_PATH);
  963. LoadString(0, s_nSkipComponent, szMessageComponent, MAX_PATH);
  964. wsprintf( szMessage, szFmt, szMessageComponent, szMessageComponent );
  965. // Ask the user and store result it s_bQuerySkipAllow
  966. if( IDYES == MessageBox( s_hwndMain, szMessage, szTitle, MB_YESNO) )
  967. s_bQuerySkipAllow = FALSE;
  968. else
  969. s_bQuerySkipAllow = TRUE;
  970. EnableWindow( s_hwndMain, TRUE );
  971. // Set the event, triggering the main thread to wake up
  972. SetEvent( s_hQuerySkipEvent );
  973. }
  974. return TRUE;
  975. case WM_COMMAND_REAL:
  976. {
  977. WORD wID = LOWORD(wparam);
  978. INT numTabs;
  979. INT iTabCur;
  980. DisplayInfo* pDisplayInfo = NULL;
  981. SoundInfo* pSoundInfo = NULL;
  982. switch(wID)
  983. {
  984. case IDEXIT:
  985. PostQuitMessage( 0 );
  986. break;
  987. case IDC_NEXT_TAB:
  988. case IDNEXT:
  989. case IDC_PREV_TAB:
  990. if( FALSE == s_bScanDone )
  991. {
  992. MessageBeep( MB_ICONEXCLAMATION );
  993. return TRUE;
  994. }
  995. numTabs = TabCtrl_GetItemCount(hwndTabs);
  996. iTabCur = TabCtrl_GetCurFocus(hwndTabs);
  997. if( wID == IDC_PREV_TAB )
  998. iTabCur += numTabs - 1;
  999. else
  1000. iTabCur++;
  1001. iTabCur %= numTabs;
  1002. TabCtrl_SetCurFocus(hwndTabs, iTabCur );
  1003. break;
  1004. case IDSAVE:
  1005. SaveInfo();
  1006. break;
  1007. case IDC_APPHELP:
  1008. ShowHelp();
  1009. break;
  1010. case IDC_RESTOREDRIVERS:
  1011. RestoreDrivers();
  1012. break;
  1013. case IDC_TESTDD:
  1014. iTabCur = TabCtrl_GetCurFocus(hwndTabs);
  1015. for (pDisplayInfo = s_pDisplayInfoFirst; iTabCur > s_iPageDisplayFirst; iTabCur--)
  1016. pDisplayInfo = pDisplayInfo->m_pDisplayInfoNext;
  1017. TestDD(s_hwndMain, pDisplayInfo);
  1018. SetupDisplayPage(TabCtrl_GetCurFocus(hwndTabs) - s_iPageDisplayFirst);
  1019. break;
  1020. case IDC_TESTD3D:
  1021. iTabCur = TabCtrl_GetCurFocus(hwndTabs);
  1022. for (pDisplayInfo = s_pDisplayInfoFirst; iTabCur > s_iPageDisplayFirst; iTabCur--)
  1023. pDisplayInfo = pDisplayInfo->m_pDisplayInfoNext;
  1024. TestD3D(s_hwndMain, pDisplayInfo);
  1025. SetupDisplayPage(TabCtrl_GetCurFocus(hwndTabs) - s_iPageDisplayFirst);
  1026. break;
  1027. case IDC_TESTSND:
  1028. iTabCur = TabCtrl_GetCurFocus(hwndTabs);
  1029. for (pSoundInfo = s_pSoundInfoFirst; iTabCur > s_iPageSoundFirst; iTabCur--)
  1030. pSoundInfo = pSoundInfo->m_pSoundInfoNext;
  1031. TestSnd(s_hwndMain, pSoundInfo);
  1032. SetupSoundPage(TabCtrl_GetCurFocus(hwndTabs) - s_iPageSoundFirst);
  1033. break;
  1034. case IDC_PORTLISTCOMBO:
  1035. if (HIWORD(wparam) == CBN_SELCHANGE)
  1036. {
  1037. LONG iItemPicked = (LONG)SendMessage(GetDlgItem(s_hwndCurPage, IDC_PORTLISTCOMBO), CB_GETCURSEL, 0, 0);
  1038. LONG iItem = 0;
  1039. MusicPort* pMusicPort;
  1040. for (pMusicPort = s_pMusicInfo->m_pMusicPortFirst; pMusicPort != NULL; pMusicPort = pMusicPort->m_pMusicPortNext)
  1041. {
  1042. if (pMusicPort->m_bOutputPort)
  1043. {
  1044. if (iItem == iItemPicked)
  1045. {
  1046. s_pMusicInfo->m_guidMusicPortTest = pMusicPort->m_guid;
  1047. break;
  1048. }
  1049. iItem++;
  1050. }
  1051. }
  1052. }
  1053. break;
  1054. case IDC_TESTMUSIC:
  1055. if (s_pMusicInfo != NULL)
  1056. TestMusic(s_hwndMain, s_pMusicInfo);
  1057. SetupMusicPage();
  1058. break;
  1059. case IDC_TESTPLAY:
  1060. {
  1061. if( s_sysInfo.m_dwDirectXVersionMajor < 8 )
  1062. {
  1063. TCHAR szMessage[MAX_PATH];
  1064. TCHAR szTitle[MAX_PATH];
  1065. LoadString(0, IDS_APPFULLNAME, szTitle, MAX_PATH);
  1066. LoadString(0, IDS_TESTNEEDSDX8, szMessage, MAX_PATH);
  1067. MessageBox(s_hwndMain, szMessage, szTitle, MB_OK);
  1068. }
  1069. else
  1070. {
  1071. if (s_pNetInfo != NULL)
  1072. TestNetwork(s_hwndMain, s_pNetInfo);
  1073. SetupNetworkPage();
  1074. }
  1075. break;
  1076. }
  1077. case IDC_DISABLEDD:
  1078. ToggleDDAccel();
  1079. break;
  1080. case IDC_DISABLED3D:
  1081. ToggleD3DAccel();
  1082. break;
  1083. case IDC_DISABLEAGP:
  1084. ToggleAGPSupport();
  1085. break;
  1086. case IDC_DISABLEDM:
  1087. ToggleDMAccel();
  1088. break;
  1089. case IDC_TROUBLESHOOT:
  1090. TroubleShoot( FALSE );
  1091. break;
  1092. case IDC_TROUBLESHOOTSOUND:
  1093. TroubleShoot( TRUE );
  1094. break;
  1095. case IDC_MSINFO:
  1096. {
  1097. HKEY hkey;
  1098. TCHAR szMsInfo[MAX_PATH];
  1099. DWORD cbData = MAX_PATH;
  1100. DWORD dwType;
  1101. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  1102. TEXT("Software\\Microsoft\\Shared Tools\\MSInfo"), 0, KEY_READ, &hkey))
  1103. {
  1104. RegQueryValueEx(hkey, TEXT("Path"), 0, &dwType, (LPBYTE)szMsInfo, &cbData);
  1105. HINSTANCE hinstResult = ShellExecute( s_hwndMain, NULL, szMsInfo, NULL,
  1106. NULL, SW_SHOWNORMAL );
  1107. if( (INT_PTR)hinstResult < 32 )
  1108. ReportError(IDS_NOMSINFO);
  1109. }
  1110. else
  1111. {
  1112. ReportError(IDS_NOMSINFO);
  1113. }
  1114. }
  1115. break;
  1116. case IDC_OVERRIDE:
  1117. OverrideDDRefresh();
  1118. break;
  1119. case IDC_GHOST:
  1120. AdjustGhostDevices(s_hwndMain, s_pDisplayInfoFirst);
  1121. break;
  1122. }
  1123. return TRUE;
  1124. }
  1125. case WM_NOTIFY:
  1126. {
  1127. INT id = (INT)wparam;
  1128. NMHDR* pnmh = (LPNMHDR)lparam;
  1129. UINT code = pnmh->code;
  1130. if (code == TCN_SELCHANGING)
  1131. {
  1132. if( !s_bScanDone )
  1133. {
  1134. MessageBeep( MB_ICONEXCLAMATION );
  1135. SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE);
  1136. return TRUE;
  1137. }
  1138. CleanupPage(hwndTabs, TabCtrl_GetCurFocus(hwndTabs));
  1139. return TRUE;
  1140. }
  1141. if (code == TCN_SELCHANGE)
  1142. SetupPage(hwndTabs, TabCtrl_GetCurFocus(hwndTabs));
  1143. // If a "DX files" column was clicked
  1144. if (code == LVN_COLUMNCLICK && s_lwCurPage == 1)
  1145. {
  1146. NMLISTVIEW* pnmv = (LPNMLISTVIEW) lparam;
  1147. // Figure out if we want to reverse sort
  1148. if( s_sortInfo.dwColumnToSort == (DWORD) pnmv->iSubItem )
  1149. s_sortInfo.nSortDirection = -s_sortInfo.nSortDirection;
  1150. else
  1151. s_sortInfo.nSortDirection = 1;
  1152. // Set the column to sort, and sort
  1153. s_sortInfo.dwColumnToSort = pnmv->iSubItem;
  1154. ListView_SortItems( GetDlgItem(s_hwndCurPage, IDC_LIST),
  1155. DXFilesCompareFunc, 0 );
  1156. }
  1157. }
  1158. return TRUE;
  1159. case WM_HSCROLL:
  1160. if ((HWND)lparam == GetDlgItem(s_hwndCurPage, IDC_SNDACCELSLIDER))
  1161. HandleSndSliderChange(LOWORD(wparam), HIWORD(wparam));
  1162. return TRUE;
  1163. case WM_CLOSE:
  1164. PostQuitMessage(0);
  1165. return TRUE;
  1166. case WM_DESTROY:
  1167. UnhookWindowsHookEx( s_hHook );
  1168. return TRUE;
  1169. }
  1170. return FALSE;
  1171. }
  1172. /****************************************************************************
  1173. *
  1174. * CreateTabs
  1175. *
  1176. ****************************************************************************/
  1177. HRESULT CreateTabs(HWND hwndTabs)
  1178. {
  1179. TC_ITEM tie;
  1180. INT i = 0;
  1181. TCHAR sz[MAX_PATH];
  1182. TCHAR szFmt[MAX_PATH];
  1183. DisplayInfo* pDisplayInfo;
  1184. SoundInfo* pSoundInfo;
  1185. tie.mask = TCIF_TEXT | TCIF_IMAGE;
  1186. tie.iImage = -1;
  1187. LoadString(NULL, IDS_HELPTAB, sz, MAX_PATH);
  1188. tie.pszText = sz;
  1189. if (TabCtrl_InsertItem(hwndTabs, i++, &tie) == -1)
  1190. return E_FAIL;
  1191. LoadString(NULL, IDS_DXFILESTAB, sz, MAX_PATH);
  1192. tie.pszText = sz;
  1193. if (TabCtrl_InsertItem(hwndTabs, i++, &tie) == -1)
  1194. return E_FAIL;
  1195. // Create tabs for each display:
  1196. s_iPageDisplayFirst = 2;
  1197. for (pDisplayInfo = s_pDisplayInfoFirst; pDisplayInfo != NULL;
  1198. pDisplayInfo = pDisplayInfo->m_pDisplayInfoNext)
  1199. {
  1200. if (pDisplayInfo == s_pDisplayInfoFirst && pDisplayInfo->m_pDisplayInfoNext == NULL)
  1201. {
  1202. LoadString(NULL, IDS_ONEDISPLAYTAB, sz, MAX_PATH);
  1203. }
  1204. else
  1205. {
  1206. LoadString(NULL, IDS_MULTIDISPLAYTAB, szFmt, MAX_PATH);
  1207. wsprintf(sz, szFmt, s_numDisplayInfo + 1);
  1208. }
  1209. tie.pszText = sz;
  1210. if (TabCtrl_InsertItem(hwndTabs, i++, &tie) == -1)
  1211. return E_FAIL;
  1212. s_numDisplayInfo++;
  1213. }
  1214. // Create tabs for each sound device:
  1215. s_iPageSoundFirst = s_iPageDisplayFirst + s_numDisplayInfo;
  1216. for (pSoundInfo = s_pSoundInfoFirst; pSoundInfo != NULL;
  1217. pSoundInfo = pSoundInfo->m_pSoundInfoNext)
  1218. {
  1219. if (pSoundInfo == s_pSoundInfoFirst && pSoundInfo->m_pSoundInfoNext == NULL)
  1220. {
  1221. LoadString(NULL, IDS_ONESOUNDTAB, sz, MAX_PATH);
  1222. }
  1223. else
  1224. {
  1225. LoadString(NULL, IDS_MULTISOUNDTAB, szFmt, MAX_PATH);
  1226. wsprintf(sz, szFmt, s_numSoundInfo + 1);
  1227. }
  1228. tie.pszText = sz;
  1229. if (TabCtrl_InsertItem(hwndTabs, i++, &tie) == -1)
  1230. return E_FAIL;
  1231. s_numSoundInfo++;
  1232. }
  1233. // Create tab for music device, if DMusic is available:
  1234. if (s_pMusicInfo != NULL)
  1235. {
  1236. s_iPageMusic = s_iPageSoundFirst + s_numSoundInfo;
  1237. LoadString(NULL, IDS_MUSICTAB, sz, MAX_PATH);
  1238. tie.pszText = sz;
  1239. if (TabCtrl_InsertItem(hwndTabs, i++, &tie) == -1)
  1240. return E_FAIL;
  1241. }
  1242. if (s_iPageMusic > 0)
  1243. s_iPageInput = s_iPageMusic + 1;
  1244. else
  1245. s_iPageInput = s_iPageSoundFirst + s_numSoundInfo;
  1246. LoadString(NULL, IDS_INPUTTAB, sz, MAX_PATH);
  1247. tie.pszText = sz;
  1248. if (TabCtrl_InsertItem(hwndTabs, i++, &tie) == -1)
  1249. return E_FAIL;
  1250. s_iPageNetwork = s_iPageInput + 1;
  1251. LoadString(NULL, IDS_NETWORKTAB, sz, MAX_PATH);
  1252. tie.pszText = sz;
  1253. if (TabCtrl_InsertItem(hwndTabs, i++, &tie) == -1)
  1254. return E_FAIL;
  1255. s_iPageStillStuck = s_iPageNetwork + 1;
  1256. LoadString(NULL, IDS_STILLSTUCKTAB, sz, MAX_PATH);
  1257. tie.pszText = sz;
  1258. if (TabCtrl_InsertItem(hwndTabs, i++, &tie) == -1)
  1259. return E_FAIL;
  1260. return S_OK;
  1261. }
  1262. /****************************************************************************
  1263. *
  1264. * SetupPage
  1265. *
  1266. ****************************************************************************/
  1267. HRESULT SetupPage(HWND hwndTabs, INT iPage)
  1268. {
  1269. HRESULT hr;
  1270. s_lwCurPage = iPage;
  1271. // Only enable "Next Page" button if not on last page:
  1272. HWND hwndNextButton = GetDlgItem(s_hwndMain, IDNEXT);
  1273. if (!s_bScanDone || iPage == TabCtrl_GetItemCount(hwndTabs) - 1)
  1274. EnableWindow(hwndNextButton, FALSE);
  1275. else
  1276. EnableWindow(hwndNextButton, TRUE);
  1277. EnableWindow(GetDlgItem(s_hwndMain, IDSAVE), s_bScanDone);
  1278. RECT rc;
  1279. WORD idDialog;
  1280. GetClientRect(hwndTabs, &rc);
  1281. TabCtrl_AdjustRect(hwndTabs, FALSE, &rc);
  1282. if (iPage == 0)
  1283. idDialog = IDD_HELPPAGE;
  1284. else if (iPage == 1)
  1285. idDialog = IDD_DXFILESPAGE;
  1286. else if (iPage >= s_iPageDisplayFirst && iPage < s_iPageDisplayFirst + s_numDisplayInfo)
  1287. idDialog = IDD_DISPLAYPAGE;
  1288. else if (iPage >= s_iPageSoundFirst && iPage < s_iPageSoundFirst + s_numSoundInfo)
  1289. idDialog = IDD_SOUNDPAGE;
  1290. else if (iPage == s_iPageMusic)
  1291. idDialog = IDD_MUSICPAGE;
  1292. else if (iPage == s_iPageInput)
  1293. idDialog = IDD_INPUTPAGE;
  1294. else if (iPage == s_iPageNetwork)
  1295. idDialog = IDD_NETWORKPAGE;
  1296. else if (iPage == s_iPageStillStuck)
  1297. idDialog = IDD_STILLSTUCKPAGE;
  1298. else
  1299. return S_OK;
  1300. HINSTANCE hinst = (HINSTANCE)GetWindowLongPtr(hwndTabs, GWLP_HINSTANCE);
  1301. s_hwndCurPage = CreateDialog(hinst, MAKEINTRESOURCE(idDialog),
  1302. s_hwndMain, PageDialogProc);
  1303. SetWindowPos(s_hwndCurPage, NULL, rc.left, rc.top, rc.right - rc.left,
  1304. rc.bottom - rc.top, 0);
  1305. if (iPage == 0)
  1306. {
  1307. if (FAILED(hr = SetupHelpPage(hwndTabs)))
  1308. return hr;
  1309. }
  1310. else if (iPage == 1)
  1311. {
  1312. if (FAILED(hr = SetupDxFilesPage()))
  1313. return hr;
  1314. }
  1315. else if (iPage >= s_iPageDisplayFirst && iPage < s_iPageDisplayFirst + s_numDisplayInfo)
  1316. {
  1317. if (FAILED(hr = SetupDisplayPage(iPage - s_iPageDisplayFirst)))
  1318. return hr;
  1319. }
  1320. else if (iPage >= s_iPageSoundFirst && iPage < s_iPageSoundFirst + s_numSoundInfo)
  1321. {
  1322. if (FAILED(hr = SetupSoundPage(iPage - s_iPageSoundFirst)))
  1323. return hr;
  1324. }
  1325. else if (iPage == s_iPageMusic)
  1326. {
  1327. if (FAILED(hr = SetupMusicPage()))
  1328. return hr;
  1329. }
  1330. else if (iPage == s_iPageInput)
  1331. {
  1332. if (FAILED(hr = SetupInputPage()))
  1333. return hr;
  1334. }
  1335. else if (iPage == s_iPageNetwork)
  1336. {
  1337. if (FAILED(hr = SetupNetworkPage()))
  1338. return hr;
  1339. }
  1340. else if (iPage == s_iPageStillStuck)
  1341. {
  1342. if (FAILED(hr = SetupStillStuckPage()))
  1343. return hr;
  1344. }
  1345. // Make sure keyboard focus is somewhere
  1346. if (GetFocus() == NULL)
  1347. SetFocus(GetDlgItem(s_hwndMain, IDSAVE));
  1348. ShowWindow(s_hwndCurPage, SW_SHOW);
  1349. return S_OK;
  1350. }
  1351. /****************************************************************************
  1352. *
  1353. * PageDialogProc
  1354. *
  1355. ****************************************************************************/
  1356. INT_PTR CALLBACK PageDialogProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
  1357. {
  1358. switch (msg)
  1359. {
  1360. case WM_INITDIALOG:
  1361. return FALSE;
  1362. case WM_COMMAND:
  1363. case WM_HSCROLL:
  1364. case WM_NOTIFY:
  1365. // Pass the message up to the main dialog proc
  1366. SendMessage(s_hwndMain, msg, wparam, lparam);
  1367. return TRUE;
  1368. }
  1369. return FALSE;
  1370. }
  1371. /****************************************************************************
  1372. *
  1373. * CleanupPage
  1374. *
  1375. ****************************************************************************/
  1376. HRESULT CleanupPage(HWND hwndTabs, INT iPage)
  1377. {
  1378. if (s_hwndCurPage != NULL)
  1379. {
  1380. DestroyWindow(s_hwndCurPage);
  1381. s_hwndCurPage = NULL;
  1382. }
  1383. return S_OK;
  1384. }
  1385. /****************************************************************************
  1386. *
  1387. * SetupHelpPage
  1388. *
  1389. ****************************************************************************/
  1390. HRESULT SetupHelpPage(HWND hwndTabs)
  1391. {
  1392. TCHAR szCopyrightFmt[MAX_PATH];
  1393. TCHAR szUnicode[MAX_PATH];
  1394. TCHAR szCopyright[MAX_PATH];
  1395. LoadString(NULL, IDS_COPYRIGHTFMT, szCopyrightFmt, MAX_PATH);
  1396. #ifdef UNICODE
  1397. LoadString(NULL, IDS_UNICODE, szUnicode, MAX_PATH);
  1398. #else
  1399. lstrcpy(szUnicode, TEXT(""));
  1400. #endif
  1401. wsprintf(szCopyright, szCopyrightFmt, s_sysInfo.m_szDxDiagVersion, szUnicode);
  1402. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DATE), s_sysInfo.m_szTimeLocal);
  1403. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_COMPUTERNAME), s_sysInfo.m_szMachine);
  1404. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_OS), s_sysInfo.m_szOSEx);
  1405. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_LANGUAGE), s_sysInfo.m_szLanguagesLocal);
  1406. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_PROCESSOR), s_sysInfo.m_szProcessor);
  1407. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_MEMORY), s_sysInfo.m_szPhysicalMemory);
  1408. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_PAGEFILE), s_sysInfo.m_szPageFile);
  1409. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DIRECTXVERSION), s_sysInfo.m_szDirectXVersionLong);
  1410. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_COPYRIGHT), szCopyright);
  1411. HWND hProgress = GetDlgItem( s_hwndCurPage, IDC_LOAD_PROGRESS );
  1412. SendMessage( hProgress, PBM_SETRANGE, 0, MAKELPARAM(0, 17 * 10) );
  1413. SendMessage( hProgress, PBM_SETPOS, 0, 0 );
  1414. ShowWindow( hProgress, !s_bScanDone ? SW_SHOW : SW_HIDE );
  1415. return S_OK;
  1416. }
  1417. /****************************************************************************
  1418. *
  1419. * ShowBullets - Show bullets and 1/4-inch indents in notes box
  1420. *
  1421. ****************************************************************************/
  1422. VOID ShowBullets(VOID)
  1423. {
  1424. PARAFORMAT pf;
  1425. ZeroMemory(&pf, sizeof(pf));
  1426. pf.cbSize = sizeof(pf);
  1427. pf.dwMask = PFM_NUMBERING | PFM_OFFSET;
  1428. pf.wNumbering = PFN_BULLET;
  1429. pf.dxOffset = 1440 / 4; // a twip is 1440th of an inch, I want a 1/4-inch indent
  1430. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES), EM_SETPARAFORMAT, 0, (LPARAM)&pf);
  1431. }
  1432. /****************************************************************************
  1433. *
  1434. * HideBullets
  1435. *
  1436. ****************************************************************************/
  1437. VOID HideBullets(VOID)
  1438. {
  1439. PARAFORMAT pf;
  1440. ZeroMemory(&pf, sizeof(pf));
  1441. pf.cbSize = sizeof(pf);
  1442. pf.dwMask = PFM_NUMBERING;
  1443. pf.wNumbering = 0;
  1444. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES), EM_SETPARAFORMAT, 0, (LPARAM)&pf);
  1445. }
  1446. /****************************************************************************
  1447. *
  1448. * SetupDxFilesPage
  1449. *
  1450. ****************************************************************************/
  1451. HRESULT SetupDxFilesPage(VOID)
  1452. {
  1453. HRESULT hr;
  1454. HWND hwndList = GetDlgItem(s_hwndCurPage, IDC_LIST);
  1455. ListView_SetImageList(hwndList, s_himgList, LVSIL_STATE);
  1456. if (FAILED(hr = (CreateFileInfoColumns(hwndList, FALSE))))
  1457. return hr;
  1458. ShowBullets();
  1459. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES),
  1460. EM_REPLACESEL, FALSE, (LPARAM)s_sysInfo.m_szDXFileNotes);
  1461. // Disable bullets so last line doesn't have an empty bullet
  1462. HideBullets();
  1463. if (FAILED(hr = (AddFileInfo(hwndList, s_pDxComponentsFileInfoFirst))))
  1464. return hr;
  1465. // Autosize all columns to fit header/text tightly:
  1466. INT iColumn = 0;
  1467. INT iWidthHeader;
  1468. INT iWidthText;
  1469. while (TRUE)
  1470. {
  1471. if (FALSE == ListView_SetColumnWidth(hwndList, iColumn, LVSCW_AUTOSIZE_USEHEADER))
  1472. break;
  1473. iWidthHeader = ListView_GetColumnWidth(hwndList, iColumn);
  1474. ListView_SetColumnWidth(hwndList, iColumn, LVSCW_AUTOSIZE);
  1475. iWidthText = ListView_GetColumnWidth(hwndList, iColumn);
  1476. if (iWidthText < iWidthHeader)
  1477. ListView_SetColumnWidth(hwndList, iColumn, iWidthHeader);
  1478. iColumn++;
  1479. }
  1480. // Delete the bogus column that was created
  1481. ListView_DeleteColumn(hwndList, iColumn - 1);
  1482. return S_OK;
  1483. }
  1484. /****************************************************************************
  1485. *
  1486. * SetupDisplayPage
  1487. *
  1488. ****************************************************************************/
  1489. HRESULT SetupDisplayPage(LONG iDisplay)
  1490. {
  1491. DisplayInfo* pDisplayInfo;
  1492. TCHAR sz[MAX_PATH];
  1493. pDisplayInfo = s_pDisplayInfoFirst;
  1494. while (iDisplay > 0)
  1495. {
  1496. pDisplayInfo = pDisplayInfo->m_pDisplayInfoNext;
  1497. iDisplay--;
  1498. }
  1499. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_ADAPTER), pDisplayInfo->m_szDescription);
  1500. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_MANUFACTURER), pDisplayInfo->m_szManufacturer);
  1501. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_CHIPTYPE), pDisplayInfo->m_szChipType);
  1502. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DACTYPE), pDisplayInfo->m_szDACType);
  1503. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DISPLAYMEMORY), pDisplayInfo->m_szDisplayMemory);
  1504. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DISPLAYMODE), pDisplayInfo->m_szDisplayMode);
  1505. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_MONITOR), pDisplayInfo->m_szMonitorName);
  1506. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DRIVERNAME), pDisplayInfo->m_szDriverName);
  1507. wsprintf(sz, TEXT("%s (%s)"), pDisplayInfo->m_szDriverVersion, pDisplayInfo->m_szDriverLanguageLocal);
  1508. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DRIVERVERSION), sz);
  1509. if (pDisplayInfo->m_bDriverSignedValid)
  1510. {
  1511. if (pDisplayInfo->m_bDriverSigned)
  1512. LoadString(NULL, IDS_YES, sz, MAX_PATH);
  1513. else
  1514. LoadString(NULL, IDS_NO, sz, MAX_PATH);
  1515. }
  1516. else
  1517. LoadString(NULL, IDS_NA, sz, MAX_PATH);
  1518. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DRIVERSIGNED), sz);
  1519. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_MINIVDD), pDisplayInfo->m_szMiniVdd);
  1520. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_VDD), pDisplayInfo->m_szVdd);
  1521. // Diagnose display again since the state may have changed
  1522. // ******* DiagnoseDisplay ********
  1523. DiagnoseDisplay(&s_sysInfo, s_pDisplayInfoFirst);
  1524. if (pDisplayInfo->m_bDDAccelerationEnabled)
  1525. {
  1526. if( pDisplayInfo->m_bNoHardware )
  1527. {
  1528. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_DISABLEDD), FALSE);
  1529. }
  1530. else
  1531. {
  1532. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_DISABLEDD), TRUE);
  1533. }
  1534. LoadString(NULL, IDS_DISABLEDD, sz, MAX_PATH);
  1535. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DISABLEDD), sz);
  1536. }
  1537. else
  1538. {
  1539. LoadString(NULL, IDS_ENABLEDD, sz, MAX_PATH);
  1540. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DISABLEDD), sz);
  1541. }
  1542. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DDSTATUS), pDisplayInfo->m_szDDStatus );
  1543. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_TESTDD), TRUE);
  1544. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_TESTD3D), TRUE);
  1545. if (pDisplayInfo->m_b3DAccelerationExists)
  1546. {
  1547. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_DISABLED3D), TRUE);
  1548. if (pDisplayInfo->m_b3DAccelerationEnabled)
  1549. {
  1550. LoadString(NULL, IDS_DISABLED3D, sz, MAX_PATH);
  1551. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DISABLED3D), sz);
  1552. }
  1553. else
  1554. {
  1555. LoadString(NULL, IDS_ENABLED3D, sz, MAX_PATH);
  1556. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DISABLED3D), sz);
  1557. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_TESTD3D), FALSE);
  1558. }
  1559. }
  1560. else
  1561. {
  1562. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_DISABLED3D), FALSE);
  1563. LoadString(NULL, IDS_DISABLED3D, sz, MAX_PATH);
  1564. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DISABLED3D), sz);
  1565. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_TESTD3D), FALSE);
  1566. }
  1567. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_D3DSTATUS), pDisplayInfo->m_szD3DStatus);
  1568. // Set AGP button text to enabled or disabled
  1569. if (pDisplayInfo->m_bAGPEnabled)
  1570. LoadString(NULL, IDS_DISABLEAGP, sz, MAX_PATH);
  1571. else
  1572. LoadString(NULL, IDS_ENABLEAGP, sz, MAX_PATH);
  1573. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DISABLEAGP), sz);
  1574. // If we are sure that AGP support doesn't exist, show "not avail" for
  1575. // status, and disable button
  1576. if ( (pDisplayInfo->m_bAGPExistenceValid && !pDisplayInfo->m_bAGPExists) ||
  1577. (!pDisplayInfo->m_bDDAccelerationEnabled) )
  1578. {
  1579. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_DISABLEAGP), FALSE);
  1580. }
  1581. else
  1582. {
  1583. // Otherwise, Show enabled/disabled status and enable button
  1584. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_DISABLEAGP), TRUE);
  1585. }
  1586. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_AGPSTATUS), pDisplayInfo->m_szAGPStatus);
  1587. // Setup notes area. Clear all text
  1588. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES), EM_SETSEL, 0, -1);
  1589. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES),
  1590. EM_REPLACESEL, FALSE, (LPARAM)"");
  1591. ShowBullets();
  1592. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES),
  1593. EM_REPLACESEL, FALSE, (LPARAM)pDisplayInfo->m_szNotes);
  1594. // Disable bullets so last line doesn't have an empty bullet
  1595. HideBullets();
  1596. return S_OK;
  1597. }
  1598. /****************************************************************************
  1599. *
  1600. * SetupSoundPage
  1601. *
  1602. ****************************************************************************/
  1603. HRESULT SetupSoundPage(LONG iSound)
  1604. {
  1605. SoundInfo* pSoundInfo;
  1606. TCHAR sz[MAX_PATH];
  1607. if( s_pSoundInfoFirst == NULL )
  1608. return S_OK;
  1609. pSoundInfo = s_pSoundInfoFirst;
  1610. while (iSound > 0)
  1611. {
  1612. pSoundInfo = pSoundInfo->m_pSoundInfoNext;
  1613. iSound--;
  1614. }
  1615. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DESCRIPTION), pSoundInfo->m_szDescription);
  1616. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DRIVERNAME), pSoundInfo->m_szDriverName);
  1617. if (lstrlen(pSoundInfo->m_szDriverName) > 0)
  1618. wsprintf(sz, TEXT("%s (%s)"), pSoundInfo->m_szDriverVersion, pSoundInfo->m_szDriverLanguageLocal);
  1619. else
  1620. lstrcpy(sz, TEXT(""));
  1621. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DRIVERVERSION), sz);
  1622. if (lstrlen(pSoundInfo->m_szDriverName) > 0)
  1623. {
  1624. if (pSoundInfo->m_bDriverSignedValid)
  1625. {
  1626. if (pSoundInfo->m_bDriverSigned)
  1627. LoadString(NULL, IDS_YES, sz, MAX_PATH);
  1628. else
  1629. LoadString(NULL, IDS_NO, sz, MAX_PATH);
  1630. }
  1631. else
  1632. LoadString(NULL, IDS_NA, sz, MAX_PATH);
  1633. }
  1634. else
  1635. lstrcpy(sz, TEXT(""));
  1636. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DRIVERSIGNED), sz);
  1637. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DEVICETYPE), pSoundInfo->m_szType);
  1638. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DEVICEID), pSoundInfo->m_szDeviceID);
  1639. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_MANUFACTURERID), pSoundInfo->m_szManufacturerID);
  1640. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_PRODUCTID), pSoundInfo->m_szProductID);
  1641. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_OTHERFILES), pSoundInfo->m_szOtherDrivers);
  1642. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_PROVIDER), pSoundInfo->m_szProvider);
  1643. if (pSoundInfo->m_lwAccelerationLevel == -1)
  1644. {
  1645. // Acceleration level cannot be read, so hide controls
  1646. ShowWindow(GetDlgItem(s_hwndCurPage, IDC_SNDACCELLABEL), SW_HIDE);
  1647. ShowWindow(GetDlgItem(s_hwndCurPage, IDC_SNDACCELDESC), SW_HIDE);
  1648. ShowWindow(GetDlgItem(s_hwndCurPage, IDC_SNDACCELSLIDER), SW_HIDE);
  1649. }
  1650. else
  1651. {
  1652. // Acceleration level can be read, so set up controls
  1653. HWND hwndSlider = GetDlgItem(s_hwndCurPage, IDC_SNDACCELSLIDER);
  1654. SendMessage(hwndSlider, TBM_SETRANGE, TRUE, MAKELONG(0, 3));
  1655. SendMessage(hwndSlider, TBM_SETTICFREQ, 1, 0);
  1656. SendMessage(hwndSlider, TBM_SETPOS, TRUE, pSoundInfo->m_lwAccelerationLevel);
  1657. switch (pSoundInfo->m_lwAccelerationLevel)
  1658. {
  1659. case 0:
  1660. LoadString(NULL, IDS_NOSNDACCELERATION, sz, MAX_PATH);
  1661. break;
  1662. case 1:
  1663. LoadString(NULL, IDS_BASICSNDACCELERATION, sz, MAX_PATH);
  1664. break;
  1665. case 2:
  1666. LoadString(NULL, IDS_STANDARDSNDACCELERATION, sz, MAX_PATH);
  1667. break;
  1668. case 3:
  1669. LoadString(NULL, IDS_FULLSNDACCELERATION, sz, MAX_PATH);
  1670. break;
  1671. default:
  1672. lstrcpy(sz, TEXT(""));
  1673. break;
  1674. }
  1675. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_SNDACCELDESC), sz);
  1676. }
  1677. // Diagnose sound again since the state may have changed
  1678. DiagnoseSound(s_pSoundInfoFirst);
  1679. ShowBullets();
  1680. // Setup notes area. Clear all text
  1681. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES), EM_SETSEL, 0, -1);
  1682. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES),
  1683. EM_REPLACESEL, FALSE, (LPARAM)"");
  1684. ShowBullets();
  1685. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES),
  1686. EM_REPLACESEL, FALSE, (LPARAM)pSoundInfo->m_szNotes);
  1687. // Disable bullets so last line doesn't have an empty bullet
  1688. HideBullets();
  1689. return S_OK;
  1690. }
  1691. /****************************************************************************
  1692. *
  1693. * SetupMusicPage
  1694. *
  1695. ****************************************************************************/
  1696. HRESULT SetupMusicPage(VOID)
  1697. {
  1698. HRESULT hr;
  1699. HWND hwndList = GetDlgItem(s_hwndCurPage, IDC_LIST);
  1700. TCHAR sz[MAX_PATH];
  1701. // Set up HW enable/disable text/button:
  1702. if (s_pMusicInfo->m_bAccelerationExists)
  1703. {
  1704. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_DISABLEDM), TRUE);
  1705. if (s_pMusicInfo->m_bAccelerationEnabled)
  1706. {
  1707. LoadString(NULL, IDS_ACCELENABLED, sz, MAX_PATH);
  1708. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DMSTATUS), sz);
  1709. LoadString(NULL, IDS_DISABLEDM, sz, MAX_PATH);
  1710. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DISABLEDM), sz);
  1711. }
  1712. else
  1713. {
  1714. LoadString(NULL, IDS_ACCELDISABLED, sz, MAX_PATH);
  1715. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DMSTATUS), sz);
  1716. LoadString(NULL, IDS_ENABLEDM, sz, MAX_PATH);
  1717. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DISABLEDM), sz);
  1718. }
  1719. }
  1720. else
  1721. {
  1722. LoadString(NULL, IDS_ACCELUNAVAIL, sz, MAX_PATH);
  1723. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DMSTATUS), sz);
  1724. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_DISABLEDM), FALSE);
  1725. LoadString(NULL, IDS_DISABLEDM, sz, MAX_PATH);
  1726. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_DISABLEDM), sz);
  1727. }
  1728. // Setup notes area. Clear all text
  1729. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES), EM_SETSEL, 0, -1);
  1730. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES),
  1731. EM_REPLACESEL, FALSE, (LPARAM)"");
  1732. // ******* DiagnoseMusic ********
  1733. DiagnoseMusic(&s_sysInfo, s_pMusicInfo);
  1734. ShowBullets();
  1735. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES),
  1736. EM_REPLACESEL, FALSE, (LPARAM)s_sysInfo.m_szMusicNotes);
  1737. // Disable bullets so last line doesn't have an empty bullet
  1738. HideBullets();
  1739. // If column 1 doesn't exist yet, create columns, fill in port info, etc.
  1740. LVCOLUMN lv;
  1741. ZeroMemory(&lv, sizeof(lv));
  1742. lv.mask = LVCF_WIDTH;
  1743. if (FALSE == ListView_GetColumn(hwndList, 1, &lv))
  1744. {
  1745. // Show GM path and version
  1746. if (s_pMusicInfo != NULL)
  1747. {
  1748. if (lstrlen(s_pMusicInfo->m_szGMFileVersion) > 0)
  1749. {
  1750. TCHAR szFmt[MAX_PATH];
  1751. LoadString(NULL, IDS_GMFILEFMT, szFmt, MAX_PATH);
  1752. wsprintf(sz, szFmt, s_pMusicInfo->m_szGMFilePath,
  1753. s_pMusicInfo->m_szGMFileVersion);
  1754. }
  1755. else
  1756. {
  1757. lstrcpy(sz, s_pMusicInfo->m_szGMFilePath);
  1758. }
  1759. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_GMPATH), sz);
  1760. }
  1761. ListView_SetImageList(hwndList, s_himgList, LVSIL_STATE);
  1762. if (FAILED(hr = (CreateMusicColumns(hwndList))))
  1763. return hr;
  1764. ListView_DeleteAllItems( hwndList );
  1765. if (FAILED(hr = (AddMusicPortInfo(hwndList, s_pMusicInfo))))
  1766. return hr;
  1767. // Autosize all columns to fit header/text tightly:
  1768. INT iColumn = 0;
  1769. INT iWidthHeader;
  1770. INT iWidthText;
  1771. while (TRUE)
  1772. {
  1773. if (FALSE == ListView_SetColumnWidth(hwndList, iColumn, LVSCW_AUTOSIZE_USEHEADER))
  1774. break;
  1775. iWidthHeader = ListView_GetColumnWidth(hwndList, iColumn);
  1776. ListView_SetColumnWidth(hwndList, iColumn, LVSCW_AUTOSIZE);
  1777. iWidthText = ListView_GetColumnWidth(hwndList, iColumn);
  1778. if (iWidthText < iWidthHeader)
  1779. ListView_SetColumnWidth(hwndList, iColumn, iWidthHeader);
  1780. iColumn++;
  1781. }
  1782. // Delete the bogus column that was created
  1783. ListView_DeleteColumn(hwndList, iColumn - 1);
  1784. // Fill in output port combo list:
  1785. MusicPort* pMusicPort;
  1786. LONG iPort = 0;
  1787. LONG iPortTestCur = 0;
  1788. SendMessage(GetDlgItem(s_hwndCurPage, IDC_PORTLISTCOMBO), CB_RESETCONTENT, 0, 0);
  1789. for (pMusicPort = s_pMusicInfo->m_pMusicPortFirst; pMusicPort != NULL;
  1790. pMusicPort = pMusicPort->m_pMusicPortNext)
  1791. {
  1792. if (pMusicPort->m_bOutputPort)
  1793. {
  1794. SendMessage(GetDlgItem(s_hwndCurPage, IDC_PORTLISTCOMBO), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)pMusicPort->m_szDescription);
  1795. if (pMusicPort->m_guid == s_pMusicInfo->m_guidMusicPortTest)
  1796. iPortTestCur = iPort;
  1797. iPort++;
  1798. }
  1799. }
  1800. SendMessage(GetDlgItem(s_hwndCurPage, IDC_PORTLISTCOMBO), CB_SETCURSEL, iPortTestCur, 0);
  1801. }
  1802. return S_OK;
  1803. }
  1804. /****************************************************************************
  1805. *
  1806. * SetupInputPage
  1807. *
  1808. ****************************************************************************/
  1809. HRESULT SetupInputPage(VOID)
  1810. {
  1811. HRESULT hr;
  1812. TCHAR sz[MAX_PATH];
  1813. // Setup notes area. Clear all text
  1814. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES), EM_SETSEL, 0, -1);
  1815. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES),
  1816. EM_REPLACESEL, FALSE, (LPARAM)"");
  1817. ShowBullets();
  1818. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES),
  1819. EM_REPLACESEL, FALSE, (LPARAM)s_sysInfo.m_szInputNotes);
  1820. // Disable bullets so last line doesn't have an empty bullet
  1821. HideBullets();
  1822. if (BIsPlatformNT())
  1823. {
  1824. if (FAILED(hr = SetupInputDevicesNT()))
  1825. return hr;
  1826. }
  1827. else
  1828. {
  1829. if (FAILED(hr = SetupInputDevices9x()))
  1830. return hr;
  1831. }
  1832. // Second list: drivers
  1833. HWND hwndList;
  1834. LV_COLUMN col;
  1835. LONG iSubItem = 0;
  1836. LV_ITEM item;
  1837. InputDriverInfo* pInputDriverInfo;
  1838. hwndList = GetDlgItem(s_hwndCurPage, IDC_DRIVERLIST);
  1839. ListView_SetImageList(hwndList, s_himgList, LVSIL_STATE);
  1840. iSubItem = 0;
  1841. col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  1842. col.fmt = LVCFMT_LEFT;
  1843. col.cx = 100;
  1844. LoadString(NULL, IDS_REGISTRYKEY, sz, MAX_PATH);
  1845. col.pszText = sz;
  1846. col.cchTextMax = 100;
  1847. col.iSubItem = iSubItem;
  1848. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  1849. return E_FAIL;
  1850. iSubItem++;
  1851. LoadString(NULL, IDS_ACTIVE, sz, MAX_PATH);
  1852. col.pszText = sz;
  1853. col.iSubItem = iSubItem;
  1854. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  1855. return E_FAIL;
  1856. iSubItem++;
  1857. LoadString(NULL, IDS_DEVICEID, sz, MAX_PATH);
  1858. col.pszText = sz;
  1859. col.iSubItem = iSubItem;
  1860. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  1861. return E_FAIL;
  1862. iSubItem++;
  1863. LoadString(NULL, IDS_MATCHINGDEVID, sz, MAX_PATH);
  1864. col.pszText = sz;
  1865. col.iSubItem = iSubItem;
  1866. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  1867. return E_FAIL;
  1868. iSubItem++;
  1869. LoadString(NULL, IDS_DRIVER16, sz, MAX_PATH);
  1870. col.pszText = sz;
  1871. col.iSubItem = iSubItem;
  1872. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  1873. return E_FAIL;
  1874. iSubItem++;
  1875. LoadString(NULL, IDS_DRIVER32, sz, MAX_PATH);
  1876. col.pszText = sz;
  1877. col.iSubItem = iSubItem;
  1878. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  1879. return E_FAIL;
  1880. iSubItem++;
  1881. // Add a bogus column so SetColumnWidth doesn't do strange
  1882. // things with the last real column
  1883. col.fmt = LVCFMT_RIGHT;
  1884. col.pszText = TEXT("");
  1885. col.iSubItem = iSubItem;
  1886. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  1887. return E_FAIL;
  1888. iSubItem++;
  1889. if( s_pInputInfo == NULL )
  1890. return S_OK;
  1891. for (pInputDriverInfo = s_pInputInfo->m_pInputDriverInfoFirst; pInputDriverInfo != NULL;
  1892. pInputDriverInfo = pInputDriverInfo->m_pInputDriverInfoNext)
  1893. {
  1894. iSubItem = 0;
  1895. item.mask = LVIF_TEXT | LVIF_STATE;
  1896. item.iItem = ListView_GetItemCount(hwndList);
  1897. item.stateMask = 0xffff;
  1898. item.cchTextMax = 100;
  1899. if (pInputDriverInfo->m_bProblem)
  1900. item.state = (1 << 12);
  1901. else
  1902. item.state = 0;
  1903. item.iSubItem = iSubItem++;
  1904. item.pszText = pInputDriverInfo->m_szRegKey;
  1905. if (-1 == ListView_InsertItem(hwndList, &item))
  1906. return E_FAIL;
  1907. item.mask = LVIF_TEXT;
  1908. item.iSubItem = iSubItem++;
  1909. if (pInputDriverInfo->m_bActive)
  1910. LoadString(NULL, IDS_YES, sz, MAX_PATH);
  1911. else
  1912. LoadString(NULL, IDS_NO, sz, MAX_PATH);
  1913. item.pszText = sz;
  1914. if (FALSE == ListView_SetItem(hwndList, &item))
  1915. return E_FAIL;
  1916. item.iSubItem = iSubItem++;
  1917. item.pszText = pInputDriverInfo->m_szDeviceID;
  1918. if (FALSE == ListView_SetItem(hwndList, &item))
  1919. return E_FAIL;
  1920. item.iSubItem = iSubItem++;
  1921. item.pszText = pInputDriverInfo->m_szMatchingDeviceID;
  1922. if (FALSE == ListView_SetItem(hwndList, &item))
  1923. return E_FAIL;
  1924. item.iSubItem = iSubItem++;
  1925. item.pszText = pInputDriverInfo->m_szDriver16;
  1926. if (FALSE == ListView_SetItem(hwndList, &item))
  1927. return E_FAIL;
  1928. item.iSubItem = iSubItem++;
  1929. item.pszText = pInputDriverInfo->m_szDriver32;
  1930. if (FALSE == ListView_SetItem(hwndList, &item))
  1931. return E_FAIL;
  1932. }
  1933. // Autosize all columns to fit header/text tightly:
  1934. INT iColumn = 0;
  1935. INT iWidthHeader;
  1936. INT iWidthText;
  1937. while (TRUE)
  1938. {
  1939. if (FALSE == ListView_SetColumnWidth(hwndList, iColumn, LVSCW_AUTOSIZE_USEHEADER))
  1940. break;
  1941. iWidthHeader = ListView_GetColumnWidth(hwndList, iColumn);
  1942. ListView_SetColumnWidth(hwndList, iColumn, LVSCW_AUTOSIZE);
  1943. iWidthText = ListView_GetColumnWidth(hwndList, iColumn);
  1944. if (iWidthText < iWidthHeader)
  1945. ListView_SetColumnWidth(hwndList, iColumn, iWidthHeader);
  1946. iColumn++;
  1947. }
  1948. // Delete the bogus column that was created
  1949. ListView_DeleteColumn(hwndList, iColumn - 1);
  1950. return S_OK;
  1951. }
  1952. /****************************************************************************
  1953. *
  1954. * SetupInputDevices9x
  1955. *
  1956. ****************************************************************************/
  1957. HRESULT SetupInputDevices9x(VOID)
  1958. {
  1959. HWND hwndList = GetDlgItem(s_hwndCurPage, IDC_LIST);
  1960. LV_COLUMN col;
  1961. LONG iSubItem = 0;
  1962. LV_ITEM item;
  1963. InputDeviceInfo* pInputDeviceInfo;
  1964. TCHAR sz[MAX_PATH];
  1965. ListView_SetImageList(hwndList, s_himgList, LVSIL_STATE);
  1966. col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  1967. col.fmt = LVCFMT_LEFT;
  1968. col.cx = 100;
  1969. LoadString(NULL, IDS_DEVICENAME, sz, MAX_PATH);
  1970. col.pszText = sz;
  1971. col.cchTextMax = 100;
  1972. col.iSubItem = iSubItem;
  1973. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  1974. return E_FAIL;
  1975. iSubItem++;
  1976. LoadString(NULL, IDS_USAGE, sz, MAX_PATH);
  1977. col.pszText = sz;
  1978. col.iSubItem = iSubItem;
  1979. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  1980. return E_FAIL;
  1981. iSubItem++;
  1982. LoadString(NULL, IDS_DRIVERNAME, sz, MAX_PATH);
  1983. col.pszText = sz;
  1984. col.iSubItem = iSubItem;
  1985. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  1986. return E_FAIL;
  1987. iSubItem++;
  1988. LoadString(NULL, IDS_VERSION, sz, MAX_PATH);
  1989. col.pszText = sz;
  1990. col.iSubItem = iSubItem;
  1991. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  1992. return E_FAIL;
  1993. iSubItem++;
  1994. LoadString(NULL, IDS_ATTRIBUTES, sz, MAX_PATH);
  1995. col.pszText = sz;
  1996. col.iSubItem = iSubItem;
  1997. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  1998. return E_FAIL;
  1999. iSubItem++;
  2000. LoadString(NULL, IDS_SIGNED, sz, MAX_PATH);
  2001. col.pszText = sz;
  2002. col.iSubItem = iSubItem;
  2003. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2004. return E_FAIL;
  2005. iSubItem++;
  2006. LoadString(NULL, IDS_LANGUAGE, sz, MAX_PATH);
  2007. col.pszText = sz;
  2008. col.iSubItem = iSubItem;
  2009. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2010. return E_FAIL;
  2011. iSubItem++;
  2012. col.fmt = LVCFMT_RIGHT;
  2013. LoadString(NULL, IDS_DATE, sz, MAX_PATH);
  2014. col.pszText = sz;
  2015. col.iSubItem = iSubItem;
  2016. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2017. return E_FAIL;
  2018. iSubItem++;
  2019. col.fmt = LVCFMT_RIGHT;
  2020. LoadString(NULL, IDS_SIZE, sz, MAX_PATH);
  2021. col.pszText = sz;
  2022. col.iSubItem = iSubItem;
  2023. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2024. return E_FAIL;
  2025. iSubItem++;
  2026. // Add a bogus column so SetColumnWidth doesn't do strange
  2027. // things with the last real column
  2028. col.fmt = LVCFMT_RIGHT;
  2029. col.pszText = TEXT("");
  2030. col.iSubItem = iSubItem;
  2031. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2032. return E_FAIL;
  2033. iSubItem++;
  2034. for (pInputDeviceInfo = s_pInputInfo->m_pInputDeviceInfoFirst; pInputDeviceInfo != NULL;
  2035. pInputDeviceInfo = pInputDeviceInfo->m_pInputDeviceInfoNext)
  2036. {
  2037. iSubItem = 0;
  2038. item.mask = LVIF_TEXT | LVIF_STATE;
  2039. item.iItem = ListView_GetItemCount(hwndList);
  2040. item.stateMask = 0xffff;
  2041. item.cchTextMax = 100;
  2042. if (pInputDeviceInfo->m_bProblem)
  2043. item.state = (1 << 12);
  2044. else
  2045. item.state = 0;
  2046. item.iSubItem = iSubItem++;
  2047. item.pszText = pInputDeviceInfo->m_szDeviceName;
  2048. if (-1 == ListView_InsertItem(hwndList, &item))
  2049. return E_FAIL;
  2050. item.mask = LVIF_TEXT;
  2051. item.iSubItem = iSubItem++;
  2052. item.pszText = pInputDeviceInfo->m_szSettings;
  2053. if (FALSE == ListView_SetItem(hwndList, &item))
  2054. return E_FAIL;
  2055. item.iSubItem = iSubItem++;
  2056. item.pszText = pInputDeviceInfo->m_szDriverName;
  2057. if (FALSE == ListView_SetItem(hwndList, &item))
  2058. return E_FAIL;
  2059. item.iSubItem = iSubItem++;
  2060. item.pszText = pInputDeviceInfo->m_szDriverVersion;
  2061. if (FALSE == ListView_SetItem(hwndList, &item))
  2062. return E_FAIL;
  2063. item.iSubItem = iSubItem++;
  2064. item.pszText = pInputDeviceInfo->m_szDriverAttributes;
  2065. if (FALSE == ListView_SetItem(hwndList, &item))
  2066. return E_FAIL;
  2067. item.iSubItem = iSubItem++;
  2068. if (pInputDeviceInfo->m_bDriverSignedValid)
  2069. {
  2070. if (pInputDeviceInfo->m_bDriverSigned)
  2071. LoadString(NULL, IDS_YES, sz, MAX_PATH);
  2072. else
  2073. LoadString(NULL, IDS_NO, sz, MAX_PATH);
  2074. }
  2075. else
  2076. LoadString(NULL, IDS_NA, sz, MAX_PATH);
  2077. item.pszText = sz;
  2078. if (FALSE == ListView_SetItem(hwndList, &item))
  2079. return E_FAIL;
  2080. item.iSubItem = iSubItem++;
  2081. item.pszText = pInputDeviceInfo->m_szDriverLanguageLocal;
  2082. if (FALSE == ListView_SetItem(hwndList, &item))
  2083. return E_FAIL;
  2084. item.iSubItem = iSubItem++;
  2085. item.pszText = pInputDeviceInfo->m_szDriverDateLocal;
  2086. if (FALSE == ListView_SetItem(hwndList, &item))
  2087. return E_FAIL;
  2088. item.iSubItem = iSubItem++;
  2089. wsprintf(sz, TEXT("%d"), pInputDeviceInfo->m_numBytes);
  2090. item.pszText = sz;
  2091. if (FALSE == ListView_SetItem(hwndList, &item))
  2092. return E_FAIL;
  2093. }
  2094. // Autosize all columns to fit header/text tightly:
  2095. INT iColumn = 0;
  2096. INT iWidthHeader;
  2097. INT iWidthText;
  2098. while (TRUE)
  2099. {
  2100. if (FALSE == ListView_SetColumnWidth(hwndList, iColumn, LVSCW_AUTOSIZE_USEHEADER))
  2101. break;
  2102. iWidthHeader = ListView_GetColumnWidth(hwndList, iColumn);
  2103. ListView_SetColumnWidth(hwndList, iColumn, LVSCW_AUTOSIZE);
  2104. iWidthText = ListView_GetColumnWidth(hwndList, iColumn);
  2105. if (iWidthText < iWidthHeader)
  2106. ListView_SetColumnWidth(hwndList, iColumn, iWidthHeader);
  2107. iColumn++;
  2108. }
  2109. // Delete the bogus column that was created
  2110. ListView_DeleteColumn(hwndList, iColumn - 1);
  2111. return S_OK;
  2112. }
  2113. /****************************************************************************
  2114. *
  2115. * SetupInputDevicesNT
  2116. *
  2117. ****************************************************************************/
  2118. HRESULT SetupInputDevicesNT(VOID)
  2119. {
  2120. HWND hwndList = GetDlgItem(s_hwndCurPage, IDC_LIST);
  2121. LV_COLUMN col;
  2122. LONG iSubItem = 0;
  2123. LV_ITEM item;
  2124. InputDeviceInfoNT* pInputDeviceInfoNT;
  2125. TCHAR sz[MAX_PATH];
  2126. ListView_SetImageList(hwndList, s_himgList, LVSIL_STATE);
  2127. col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  2128. col.fmt = LVCFMT_LEFT;
  2129. col.cx = 100;
  2130. LoadString(NULL, IDS_DEVICENAME, sz, MAX_PATH);
  2131. col.pszText = sz;
  2132. col.cchTextMax = 100;
  2133. col.iSubItem = iSubItem;
  2134. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2135. return E_FAIL;
  2136. iSubItem++;
  2137. LoadString(NULL, IDS_PROVIDER, sz, MAX_PATH);
  2138. col.pszText = sz;
  2139. col.iSubItem = iSubItem;
  2140. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2141. return E_FAIL;
  2142. iSubItem++;
  2143. LoadString(NULL, IDS_DEVICEID, sz, MAX_PATH);
  2144. col.pszText = sz;
  2145. col.iSubItem = iSubItem;
  2146. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2147. return E_FAIL;
  2148. iSubItem++;
  2149. LoadString(NULL, IDS_STATUS, sz, MAX_PATH);
  2150. col.pszText = sz;
  2151. col.iSubItem = iSubItem;
  2152. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2153. return E_FAIL;
  2154. iSubItem++;
  2155. LoadString(NULL, IDS_PORTNAME, sz, MAX_PATH);
  2156. col.pszText = sz;
  2157. col.iSubItem = iSubItem;
  2158. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2159. return E_FAIL;
  2160. iSubItem++;
  2161. LoadString(NULL, IDS_PORTPROVIDER, sz, MAX_PATH);
  2162. col.pszText = sz;
  2163. col.iSubItem = iSubItem;
  2164. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2165. return E_FAIL;
  2166. iSubItem++;
  2167. LoadString(NULL, IDS_PORTID, sz, MAX_PATH);
  2168. col.pszText = sz;
  2169. col.iSubItem = iSubItem;
  2170. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2171. return E_FAIL;
  2172. iSubItem++;
  2173. LoadString(NULL, IDS_PORTSTATUS, sz, MAX_PATH);
  2174. col.pszText = sz;
  2175. col.iSubItem = iSubItem;
  2176. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2177. return E_FAIL;
  2178. iSubItem++;
  2179. // Add a bogus column so SetColumnWidth doesn't do strange
  2180. // things with the last real column
  2181. col.fmt = LVCFMT_RIGHT;
  2182. col.pszText = TEXT("");
  2183. col.iSubItem = iSubItem;
  2184. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2185. return E_FAIL;
  2186. iSubItem++;
  2187. if( s_pInputInfo == NULL )
  2188. return S_OK;
  2189. for (pInputDeviceInfoNT = s_pInputInfo->m_pInputDeviceInfoNTFirst; pInputDeviceInfoNT != NULL;
  2190. pInputDeviceInfoNT = pInputDeviceInfoNT->m_pInputDeviceInfoNTNext)
  2191. {
  2192. iSubItem = 0;
  2193. item.mask = LVIF_TEXT | LVIF_STATE;
  2194. item.iItem = ListView_GetItemCount(hwndList);
  2195. item.stateMask = 0xffff;
  2196. item.cchTextMax = 100;
  2197. if (pInputDeviceInfoNT->m_bProblem)
  2198. item.state = (1 << 12);
  2199. else
  2200. item.state = 0;
  2201. item.iSubItem = iSubItem++;
  2202. item.pszText = pInputDeviceInfoNT->m_szName;
  2203. if (-1 == ListView_InsertItem(hwndList, &item))
  2204. return E_FAIL;
  2205. item.mask = LVIF_TEXT;
  2206. item.iSubItem = iSubItem++;
  2207. item.pszText = pInputDeviceInfoNT->m_szProvider;
  2208. if (FALSE == ListView_SetItem(hwndList, &item))
  2209. return E_FAIL;
  2210. item.iSubItem = iSubItem++;
  2211. item.pszText = pInputDeviceInfoNT->m_szId;
  2212. if (FALSE == ListView_SetItem(hwndList, &item))
  2213. return E_FAIL;
  2214. wsprintf(sz, TEXT("0x%x, 0x%x"), pInputDeviceInfoNT->m_dwStatus, pInputDeviceInfoNT->m_dwProblem);
  2215. item.iSubItem = iSubItem++;
  2216. item.pszText = sz;
  2217. if (FALSE == ListView_SetItem(hwndList, &item))
  2218. return E_FAIL;
  2219. item.iSubItem = iSubItem++;
  2220. item.pszText = pInputDeviceInfoNT->m_szPortName;
  2221. if (FALSE == ListView_SetItem(hwndList, &item))
  2222. return E_FAIL;
  2223. item.iSubItem = iSubItem++;
  2224. item.pszText = pInputDeviceInfoNT->m_szPortProvider;
  2225. if (FALSE == ListView_SetItem(hwndList, &item))
  2226. return E_FAIL;
  2227. item.iSubItem = iSubItem++;
  2228. item.pszText = pInputDeviceInfoNT->m_szPortId;
  2229. if (FALSE == ListView_SetItem(hwndList, &item))
  2230. return E_FAIL;
  2231. wsprintf(sz, TEXT("0x%x, 0x%x"), pInputDeviceInfoNT->m_dwPortStatus, pInputDeviceInfoNT->m_dwPortProblem);
  2232. item.iSubItem = iSubItem++;
  2233. item.pszText = sz;
  2234. if (FALSE == ListView_SetItem(hwndList, &item))
  2235. return E_FAIL;
  2236. }
  2237. // Autosize all columns to fit header/text tightly:
  2238. INT iColumn = 0;
  2239. INT iWidthHeader;
  2240. INT iWidthText;
  2241. while (TRUE)
  2242. {
  2243. if (FALSE == ListView_SetColumnWidth(hwndList, iColumn, LVSCW_AUTOSIZE_USEHEADER))
  2244. break;
  2245. iWidthHeader = ListView_GetColumnWidth(hwndList, iColumn);
  2246. ListView_SetColumnWidth(hwndList, iColumn, LVSCW_AUTOSIZE);
  2247. iWidthText = ListView_GetColumnWidth(hwndList, iColumn);
  2248. if (iWidthText < iWidthHeader)
  2249. ListView_SetColumnWidth(hwndList, iColumn, iWidthHeader);
  2250. iColumn++;
  2251. }
  2252. // Delete the bogus column that was created
  2253. ListView_DeleteColumn(hwndList, iColumn - 1);
  2254. return S_OK;
  2255. }
  2256. /****************************************************************************
  2257. *
  2258. * SetupNetworkPage
  2259. *
  2260. ****************************************************************************/
  2261. HRESULT SetupNetworkPage(VOID)
  2262. {
  2263. TCHAR sz[MAX_PATH];
  2264. // Diagnose net info again since the state may have changed
  2265. // ******* DiagnoseNetInfo ********
  2266. DiagnoseNetInfo(&s_sysInfo, s_pNetInfo);
  2267. // Setup notes area. Clear all text
  2268. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES), EM_SETSEL, 0, -1);
  2269. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES),
  2270. EM_REPLACESEL, FALSE, (LPARAM)"");
  2271. ShowBullets();
  2272. SendMessage(GetDlgItem(s_hwndCurPage, IDC_NOTES),
  2273. EM_REPLACESEL, FALSE, (LPARAM)s_sysInfo.m_szNetworkNotes);
  2274. // Disable bullets so last line doesn't have an empty bullet
  2275. HideBullets();
  2276. if( s_pNetInfo == NULL )
  2277. return S_OK;
  2278. // If column 1 doesn't exist yet, create columns, fill in port info, etc.
  2279. HWND hwndList = GetDlgItem(s_hwndCurPage, IDC_DPSPLIST);
  2280. LVCOLUMN lv;
  2281. ZeroMemory(&lv, sizeof(lv));
  2282. lv.mask = LVCF_WIDTH;
  2283. if (FALSE == ListView_GetColumn(hwndList, 1, &lv))
  2284. {
  2285. // Set up service provider list
  2286. LV_COLUMN col;
  2287. LONG iSubItem = 0;
  2288. LV_ITEM item;
  2289. NetSP* pNetSP;
  2290. NetApp* pNetApp;
  2291. // First list: service providers
  2292. ListView_SetImageList(hwndList, s_himgList, LVSIL_STATE);
  2293. col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  2294. col.fmt = LVCFMT_LEFT;
  2295. col.cx = 100;
  2296. LoadString(NULL, IDS_NAME, sz, MAX_PATH);
  2297. col.pszText = sz;
  2298. col.cchTextMax = 100;
  2299. col.iSubItem = iSubItem;
  2300. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2301. return E_FAIL;
  2302. iSubItem++;
  2303. LoadString(NULL, IDS_REGISTRY, sz, MAX_PATH);
  2304. col.pszText = sz;
  2305. col.iSubItem = iSubItem;
  2306. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2307. return E_FAIL;
  2308. iSubItem++;
  2309. LoadString(NULL, IDS_FILE, sz, MAX_PATH);
  2310. col.pszText = sz;
  2311. col.iSubItem = iSubItem;
  2312. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2313. return E_FAIL;
  2314. iSubItem++;
  2315. LoadString(NULL, IDS_VERSION, sz, MAX_PATH);
  2316. col.pszText = sz;
  2317. col.iSubItem = iSubItem;
  2318. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2319. return E_FAIL;
  2320. iSubItem++;
  2321. // Add a bogus column so SetColumnWidth doesn't do strange
  2322. // things with the last real column
  2323. col.fmt = LVCFMT_RIGHT;
  2324. col.pszText = TEXT("");
  2325. col.iSubItem = iSubItem;
  2326. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2327. return E_FAIL;
  2328. iSubItem++;
  2329. for (pNetSP = s_pNetInfo->m_pNetSPFirst; pNetSP != NULL;
  2330. pNetSP = pNetSP->m_pNetSPNext)
  2331. {
  2332. iSubItem = 0;
  2333. item.mask = LVIF_TEXT | LVIF_STATE;
  2334. item.iItem = ListView_GetItemCount(hwndList);
  2335. item.stateMask = 0xffff;
  2336. item.cchTextMax = 100;
  2337. if (pNetSP->m_bProblem)
  2338. item.state = (1 << 12);
  2339. else
  2340. item.state = 0;
  2341. item.iSubItem = iSubItem++;
  2342. item.pszText = pNetSP->m_szName;
  2343. if (-1 == ListView_InsertItem(hwndList, &item))
  2344. return E_FAIL;
  2345. item.mask = LVIF_TEXT;
  2346. item.iSubItem = iSubItem++;
  2347. if (pNetSP->m_bRegistryOK)
  2348. LoadString(NULL, IDS_OK, sz, MAX_PATH);
  2349. else
  2350. LoadString(NULL, IDS_ERROR, sz, MAX_PATH);
  2351. item.pszText = sz;
  2352. if (FALSE == ListView_SetItem(hwndList, &item))
  2353. return E_FAIL;
  2354. item.iSubItem = iSubItem++;
  2355. item.pszText = pNetSP->m_szFile;
  2356. if (FALSE == ListView_SetItem(hwndList, &item))
  2357. return E_FAIL;
  2358. item.iSubItem = iSubItem++;
  2359. item.pszText = pNetSP->m_szVersion;
  2360. if (FALSE == ListView_SetItem(hwndList, &item))
  2361. return E_FAIL;
  2362. }
  2363. // Autosize all columns to fit header/text tightly:
  2364. INT iColumn = 0;
  2365. INT iWidthHeader;
  2366. INT iWidthText;
  2367. while (TRUE)
  2368. {
  2369. if (FALSE == ListView_SetColumnWidth(hwndList, iColumn, LVSCW_AUTOSIZE_USEHEADER))
  2370. break;
  2371. iWidthHeader = ListView_GetColumnWidth(hwndList, iColumn);
  2372. ListView_SetColumnWidth(hwndList, iColumn, LVSCW_AUTOSIZE);
  2373. iWidthText = ListView_GetColumnWidth(hwndList, iColumn);
  2374. if (iWidthText < iWidthHeader)
  2375. ListView_SetColumnWidth(hwndList, iColumn, iWidthHeader);
  2376. iColumn++;
  2377. }
  2378. // Delete the bogus column that was created
  2379. ListView_DeleteColumn(hwndList, iColumn - 1);
  2380. // Second list: lobbyable apps
  2381. hwndList = GetDlgItem(s_hwndCurPage, IDC_DPALIST);
  2382. ListView_SetImageList(hwndList, s_himgList, LVSIL_STATE);
  2383. iSubItem = 0;
  2384. col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  2385. col.fmt = LVCFMT_LEFT;
  2386. col.cx = 100;
  2387. LoadString(NULL, IDS_NAME, sz, MAX_PATH);
  2388. col.pszText = sz;
  2389. col.cchTextMax = 100;
  2390. col.iSubItem = iSubItem;
  2391. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2392. return E_FAIL;
  2393. iSubItem++;
  2394. LoadString(NULL, IDS_REGISTRY, sz, MAX_PATH);
  2395. col.pszText = sz;
  2396. col.iSubItem = iSubItem;
  2397. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2398. return E_FAIL;
  2399. iSubItem++;
  2400. LoadString(NULL, IDS_FILE, sz, MAX_PATH);
  2401. col.pszText = sz;
  2402. col.iSubItem = iSubItem;
  2403. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2404. return E_FAIL;
  2405. iSubItem++;
  2406. LoadString(NULL, IDS_VERSION, sz, MAX_PATH);
  2407. col.pszText = sz;
  2408. col.iSubItem = iSubItem;
  2409. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2410. return E_FAIL;
  2411. iSubItem++;
  2412. LoadString(NULL, IDS_GUID, sz, MAX_PATH);
  2413. col.pszText = sz;
  2414. col.iSubItem = iSubItem;
  2415. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2416. return E_FAIL;
  2417. iSubItem++;
  2418. // Add a bogus column so SetColumnWidth doesn't do strange
  2419. // things with the last real column
  2420. col.fmt = LVCFMT_RIGHT;
  2421. col.pszText = TEXT("");
  2422. col.iSubItem = iSubItem;
  2423. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2424. return E_FAIL;
  2425. iSubItem++;
  2426. for (pNetApp = s_pNetInfo->m_pNetAppFirst; pNetApp != NULL;
  2427. pNetApp = pNetApp->m_pNetAppNext)
  2428. {
  2429. iSubItem = 0;
  2430. item.mask = LVIF_TEXT | LVIF_STATE;
  2431. item.iItem = ListView_GetItemCount(hwndList);
  2432. item.stateMask = 0xffff;
  2433. item.cchTextMax = 100;
  2434. if (pNetApp->m_bProblem)
  2435. item.state = (1 << 12);
  2436. else
  2437. item.state = 0;
  2438. item.iSubItem = iSubItem++;
  2439. item.pszText = pNetApp->m_szName;
  2440. if (-1 == ListView_InsertItem(hwndList, &item))
  2441. return E_FAIL;
  2442. item.mask = LVIF_TEXT;
  2443. item.iSubItem = iSubItem++;
  2444. if (pNetApp->m_bRegistryOK)
  2445. LoadString(NULL, IDS_OK, sz, MAX_PATH);
  2446. else
  2447. LoadString(NULL, IDS_ERROR, sz, MAX_PATH);
  2448. item.pszText = sz;
  2449. if (FALSE == ListView_SetItem(hwndList, &item))
  2450. return E_FAIL;
  2451. item.iSubItem = iSubItem++;
  2452. item.pszText = pNetApp->m_szExeFile;
  2453. if (FALSE == ListView_SetItem(hwndList, &item))
  2454. return E_FAIL;
  2455. item.iSubItem = iSubItem++;
  2456. item.pszText = pNetApp->m_szExeVersion;
  2457. if (FALSE == ListView_SetItem(hwndList, &item))
  2458. return E_FAIL;
  2459. item.iSubItem = iSubItem++;
  2460. item.pszText = pNetApp->m_szGuid;
  2461. if (FALSE == ListView_SetItem(hwndList, &item))
  2462. return E_FAIL;
  2463. }
  2464. // Autosize all columns to fit header/text tightly:
  2465. iColumn = 0;
  2466. iWidthHeader;
  2467. iWidthText;
  2468. while (TRUE)
  2469. {
  2470. if (FALSE == ListView_SetColumnWidth(hwndList, iColumn, LVSCW_AUTOSIZE_USEHEADER))
  2471. break;
  2472. iWidthHeader = ListView_GetColumnWidth(hwndList, iColumn);
  2473. ListView_SetColumnWidth(hwndList, iColumn, LVSCW_AUTOSIZE);
  2474. iWidthText = ListView_GetColumnWidth(hwndList, iColumn);
  2475. if (iWidthText < iWidthHeader)
  2476. ListView_SetColumnWidth(hwndList, iColumn, iWidthHeader);
  2477. iColumn++;
  2478. }
  2479. // Delete the bogus column that was created
  2480. ListView_DeleteColumn(hwndList, iColumn - 1);
  2481. }
  2482. return S_OK;
  2483. }
  2484. /****************************************************************************
  2485. *
  2486. * SetupStillStuckPage
  2487. *
  2488. ****************************************************************************/
  2489. HRESULT SetupStillStuckPage(VOID)
  2490. {
  2491. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_TROUBLESHOOT), FALSE );
  2492. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_TROUBLESHOOTSOUND), FALSE );
  2493. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_MSINFO), FALSE );
  2494. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_RESTOREDRIVERS), FALSE );
  2495. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_REPORTBUG), FALSE );
  2496. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_GHOST), FALSE );
  2497. // Hide "Troubleshooter" text/button if help file not found
  2498. BOOL bFound;
  2499. TCHAR szHelpPath[MAX_PATH];
  2500. TCHAR szHelpLeaf[MAX_PATH];
  2501. TCHAR szTroubleshooter[MAX_PATH];
  2502. if( GetWindowsDirectory(szHelpPath, MAX_PATH) != 0 )
  2503. {
  2504. LoadString(NULL, IDS_HELPDIRLEAF, szHelpLeaf, MAX_PATH);
  2505. lstrcat(szHelpPath, szHelpLeaf);
  2506. if( BIsWin98() || BIsWin95() )
  2507. LoadString(NULL, IDS_TROUBLESHOOTER_WIN98SE, szTroubleshooter, MAX_PATH);
  2508. else if( BIsWinME() )
  2509. LoadString(NULL, IDS_TROUBLESHOOTER_WINME, szTroubleshooter, MAX_PATH);
  2510. else if( BIsWin2k() || BIsWhistler() )
  2511. LoadString(NULL, IDS_TROUBLESHOOTER_WIN2K, szTroubleshooter, MAX_PATH);
  2512. bFound = FALSE;
  2513. lstrcat(szHelpPath, TEXT("\\"));
  2514. lstrcat(szHelpPath, szTroubleshooter);
  2515. if (GetFileAttributes(szHelpPath) != 0xffffffff)
  2516. {
  2517. bFound = TRUE;
  2518. }
  2519. else if( BIsWin98() || BIsWin95() )
  2520. {
  2521. if( GetWindowsDirectory(szHelpPath, MAX_PATH) != 0 )
  2522. {
  2523. LoadString(NULL, IDS_HELPDIRLEAF, szHelpLeaf, MAX_PATH);
  2524. lstrcat(szHelpPath, szHelpLeaf);
  2525. lstrcat(szHelpPath, TEXT("\\"));
  2526. LoadString(NULL, IDS_TROUBLESHOOTER_WIN98, szTroubleshooter, MAX_PATH);
  2527. lstrcat(szHelpPath, szTroubleshooter);
  2528. if (GetFileAttributes(szHelpPath) != 0xffffffff)
  2529. bFound = TRUE;
  2530. }
  2531. }
  2532. if( bFound )
  2533. {
  2534. ShowWindow(GetDlgItem(s_hwndCurPage, IDC_TROUBLESHOOT), SW_SHOW);
  2535. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_TROUBLESHOOT), TRUE);
  2536. ShowWindow(GetDlgItem(s_hwndCurPage, IDC_TROUBLESHOOTTEXT), SW_SHOW);
  2537. }
  2538. }
  2539. // Hide "Sound Troubleshooter" text/button if help file not found
  2540. if( GetWindowsDirectory(szHelpPath, MAX_PATH) != 0 )
  2541. {
  2542. LoadString(NULL, IDS_HELPDIRLEAF, szHelpLeaf, MAX_PATH);
  2543. lstrcat(szHelpPath, szHelpLeaf);
  2544. if( BIsWin98() || BIsWin95() )
  2545. LoadString(NULL, IDS_TROUBLESHOOTER_WIN98SE, szTroubleshooter, MAX_PATH);
  2546. else if( BIsWinME() )
  2547. LoadString(NULL, IDS_TROUBLESHOOTER_WINME, szTroubleshooter, MAX_PATH);
  2548. else if( BIsWin2k() || BIsWhistler() )
  2549. LoadString(NULL, IDS_TROUBLESHOOTER_WIN2K, szTroubleshooter, MAX_PATH);
  2550. bFound = FALSE;
  2551. lstrcat(szHelpPath, TEXT("\\"));
  2552. lstrcat(szHelpPath, szTroubleshooter);
  2553. if (GetFileAttributes(szHelpPath) != 0xffffffff)
  2554. {
  2555. bFound = TRUE;
  2556. }
  2557. else if( BIsWin98() || BIsWin95() )
  2558. {
  2559. if( GetWindowsDirectory(szHelpPath, MAX_PATH) != 0 )
  2560. {
  2561. LoadString(NULL, IDS_HELPDIRLEAF, szHelpLeaf, MAX_PATH);
  2562. lstrcat(szHelpPath, szHelpLeaf);
  2563. lstrcat(szHelpPath, TEXT("\\"));
  2564. LoadString(NULL, IDS_SOUNDTROUBLESHOOTER_WIN98, szTroubleshooter, MAX_PATH);
  2565. lstrcat(szHelpPath, szTroubleshooter);
  2566. if (GetFileAttributes(szHelpPath) != 0xffffffff)
  2567. bFound = TRUE;
  2568. }
  2569. }
  2570. if( bFound )
  2571. {
  2572. ShowWindow(GetDlgItem(s_hwndCurPage, IDC_TROUBLESHOOTSOUND), SW_SHOW);
  2573. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_TROUBLESHOOTSOUND), TRUE);
  2574. ShowWindow(GetDlgItem(s_hwndCurPage, IDC_TROUBLESHOOTSOUNDTEXT), SW_SHOW);
  2575. }
  2576. }
  2577. // Hide "MSInfo" text/button if msinfo32.exe not found
  2578. HKEY hkey;
  2579. TCHAR szMsInfo[MAX_PATH];
  2580. DWORD cbData = MAX_PATH;
  2581. DWORD dwType;
  2582. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  2583. TEXT("Software\\Microsoft\\Shared Tools\\MSInfo"), 0, KEY_READ, &hkey))
  2584. {
  2585. RegQueryValueEx(hkey, TEXT("Path"), 0, &dwType, (LPBYTE)szMsInfo, &cbData);
  2586. if (GetFileAttributes(szMsInfo) != 0xffffffff)
  2587. {
  2588. ShowWindow(GetDlgItem(s_hwndCurPage, IDC_MSINFO), SW_SHOW);
  2589. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_MSINFO), TRUE);
  2590. ShowWindow(GetDlgItem(s_hwndCurPage, IDC_MSINFOTEXT), SW_SHOW);
  2591. }
  2592. RegCloseKey(hkey);
  2593. }
  2594. // Hide "Restore" text/button if dxsetup.exe not found
  2595. if (BCanRestoreDrivers())
  2596. {
  2597. ShowWindow(GetDlgItem(s_hwndCurPage, IDC_RESTOREDRIVERS), SW_SHOW);
  2598. ShowWindow(GetDlgItem(s_hwndCurPage, IDC_RESTOREDRIVERSTEXT), SW_SHOW);
  2599. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_RESTOREDRIVERS), TRUE);
  2600. }
  2601. // Only show "Adjust Ghost Devices" text/button if s_bGhost is set and not NT
  2602. if (s_bGhost && !BIsPlatformNT())
  2603. {
  2604. ShowWindow(GetDlgItem(s_hwndCurPage, IDC_GHOST), SW_SHOW);
  2605. EnableWindow(GetDlgItem(s_hwndCurPage, IDC_GHOST), TRUE);
  2606. ShowWindow(GetDlgItem(s_hwndCurPage, IDC_GHOSTTEXT), SW_SHOW);
  2607. }
  2608. return S_OK;
  2609. }
  2610. /****************************************************************************
  2611. *
  2612. * CreateFileInfoColumns
  2613. *
  2614. ****************************************************************************/
  2615. HRESULT CreateFileInfoColumns(HWND hwndList, BOOL bDrivers)
  2616. {
  2617. LV_COLUMN col;
  2618. LONG iSubItem = 0;
  2619. TCHAR sz[MAX_PATH];
  2620. col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  2621. col.fmt = LVCFMT_LEFT;
  2622. col.cx = 100;
  2623. LoadString(NULL, IDS_NAME, sz, MAX_PATH);
  2624. col.pszText = sz;
  2625. col.cchTextMax = 100;
  2626. col.iSubItem = iSubItem;
  2627. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2628. return E_FAIL;
  2629. iSubItem++;
  2630. LoadString(NULL, IDS_VERSION, sz, MAX_PATH);
  2631. col.pszText = sz;
  2632. col.iSubItem = iSubItem;
  2633. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2634. return E_FAIL;
  2635. iSubItem++;
  2636. if (bDrivers)
  2637. {
  2638. LoadString(NULL, IDS_SIGNED, sz, MAX_PATH);
  2639. col.pszText = sz;
  2640. col.iSubItem = iSubItem;
  2641. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2642. return E_FAIL;
  2643. iSubItem++;
  2644. }
  2645. else
  2646. {
  2647. LoadString(NULL, IDS_ATTRIBUTES, sz, MAX_PATH);
  2648. col.pszText = sz;
  2649. col.iSubItem = iSubItem;
  2650. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2651. return E_FAIL;
  2652. iSubItem++;
  2653. }
  2654. LoadString(NULL, IDS_LANGUAGE, sz, MAX_PATH);
  2655. col.pszText = sz;
  2656. col.iSubItem = iSubItem;
  2657. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2658. return E_FAIL;
  2659. iSubItem++;
  2660. col.fmt = LVCFMT_RIGHT;
  2661. LoadString(NULL, IDS_DATE, sz, MAX_PATH);
  2662. col.pszText = sz;
  2663. col.iSubItem = iSubItem;
  2664. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2665. return E_FAIL;
  2666. iSubItem++;
  2667. col.fmt = LVCFMT_RIGHT;
  2668. LoadString(NULL, IDS_SIZE, sz, MAX_PATH);
  2669. col.pszText = sz;
  2670. col.iSubItem = iSubItem;
  2671. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2672. return E_FAIL;
  2673. iSubItem++;
  2674. // Add a bogus column so SetColumnWidth doesn't do strange
  2675. // things with the last real column
  2676. col.fmt = LVCFMT_RIGHT;
  2677. col.pszText = TEXT("");
  2678. col.iSubItem = iSubItem;
  2679. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2680. return E_FAIL;
  2681. iSubItem++;
  2682. return S_OK;
  2683. }
  2684. /****************************************************************************
  2685. *
  2686. * AddFileInfo
  2687. *
  2688. ****************************************************************************/
  2689. HRESULT AddFileInfo(HWND hwndList, FileInfo* pFileInfoFirst, BOOL bDrivers)
  2690. {
  2691. FileInfo* pFileInfo;
  2692. LV_ITEM item;
  2693. LONG iSubItem;
  2694. TCHAR sz[MAX_PATH];
  2695. for (pFileInfo = pFileInfoFirst; pFileInfo != NULL;
  2696. pFileInfo = pFileInfo->m_pFileInfoNext)
  2697. {
  2698. // Don't list missing files unless they're a "problem"
  2699. if (!pFileInfo->m_bExists && !pFileInfo->m_bProblem)
  2700. continue;
  2701. // manbugs 16765: don't list obsolete files
  2702. if (pFileInfo->m_bObsolete)
  2703. continue;
  2704. iSubItem = 0;
  2705. item.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM;
  2706. item.iItem = ListView_GetItemCount(hwndList);
  2707. item.stateMask = 0xffff;
  2708. item.cchTextMax = 100;
  2709. item.lParam = (LPARAM) pFileInfo;
  2710. if (pFileInfo->m_bProblem)
  2711. item.state = (1 << 12);
  2712. else
  2713. item.state = 0;
  2714. item.iSubItem = iSubItem++;
  2715. item.pszText = pFileInfo->m_szName;
  2716. if (-1 == ListView_InsertItem(hwndList, &item))
  2717. return E_FAIL;
  2718. item.mask = LVIF_TEXT;
  2719. item.iSubItem = iSubItem++;
  2720. item.pszText = pFileInfo->m_szVersion;
  2721. if (FALSE == ListView_SetItem(hwndList, &item))
  2722. return E_FAIL;
  2723. if (bDrivers)
  2724. {
  2725. item.iSubItem = iSubItem++;
  2726. if (DXUtil_strcmpi(TEXT(".drv"), _tcsrchr(pFileInfo->m_szName, '.')) == 0)
  2727. {
  2728. if (pFileInfo->m_bSigned)
  2729. LoadString(NULL, IDS_YES, sz, MAX_PATH);
  2730. else
  2731. LoadString(NULL, IDS_NO, sz, MAX_PATH);
  2732. }
  2733. else
  2734. {
  2735. LoadString(NULL, IDS_NA, sz, MAX_PATH);
  2736. }
  2737. item.pszText = sz;
  2738. if (FALSE == ListView_SetItem(hwndList, &item))
  2739. return E_FAIL;
  2740. }
  2741. else
  2742. {
  2743. item.iSubItem = iSubItem++;
  2744. item.pszText = pFileInfo->m_szAttributes;
  2745. if (FALSE == ListView_SetItem(hwndList, &item))
  2746. return E_FAIL;
  2747. }
  2748. item.iSubItem = iSubItem++;
  2749. item.pszText = pFileInfo->m_szLanguageLocal;
  2750. if (FALSE == ListView_SetItem(hwndList, &item))
  2751. return E_FAIL;
  2752. item.iSubItem = iSubItem++;
  2753. item.pszText = pFileInfo->m_szDatestampLocal;
  2754. if (FALSE == ListView_SetItem(hwndList, &item))
  2755. return E_FAIL;
  2756. item.iSubItem = iSubItem++;
  2757. wsprintf(sz, TEXT("%d"), pFileInfo->m_numBytes);
  2758. item.pszText = sz;
  2759. if (FALSE == ListView_SetItem(hwndList, &item))
  2760. return E_FAIL;
  2761. }
  2762. return S_OK;
  2763. }
  2764. /****************************************************************************
  2765. *
  2766. * CreateMusicColumns
  2767. *
  2768. ****************************************************************************/
  2769. HRESULT CreateMusicColumns(HWND hwndList)
  2770. {
  2771. LV_COLUMN col;
  2772. LONG iSubItem = 0;
  2773. TCHAR sz[MAX_PATH];
  2774. col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  2775. col.fmt = LVCFMT_LEFT;
  2776. col.cx = 100;
  2777. LoadString(NULL, IDS_DESCRIPTION, sz, MAX_PATH);
  2778. col.pszText = sz;
  2779. col.cchTextMax = 100;
  2780. col.iSubItem = iSubItem;
  2781. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2782. return E_FAIL;
  2783. iSubItem++;
  2784. LoadString(NULL, IDS_TYPE, sz, MAX_PATH);
  2785. col.pszText = sz;
  2786. col.iSubItem = iSubItem;
  2787. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2788. return E_FAIL;
  2789. iSubItem++;
  2790. LoadString(NULL, IDS_KERNELMODE, sz, MAX_PATH);
  2791. col.fmt = LVCFMT_RIGHT;
  2792. col.pszText = sz;
  2793. col.iSubItem = iSubItem;
  2794. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2795. return E_FAIL;
  2796. iSubItem++;
  2797. LoadString(NULL, IDS_INOUT, sz, MAX_PATH);
  2798. col.pszText = sz;
  2799. col.iSubItem = iSubItem;
  2800. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2801. return E_FAIL;
  2802. iSubItem++;
  2803. LoadString(NULL, IDS_DLS, sz, MAX_PATH);
  2804. col.fmt = LVCFMT_RIGHT;
  2805. col.pszText = sz;
  2806. col.iSubItem = iSubItem;
  2807. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2808. return E_FAIL;
  2809. iSubItem++;
  2810. LoadString(NULL, IDS_EXTERNAL, sz, MAX_PATH);
  2811. col.fmt = LVCFMT_RIGHT;
  2812. col.pszText = sz;
  2813. col.iSubItem = iSubItem;
  2814. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2815. return E_FAIL;
  2816. iSubItem++;
  2817. LoadString(NULL, IDS_DEFAULTPORT, sz, MAX_PATH);
  2818. col.fmt = LVCFMT_RIGHT;
  2819. col.pszText = sz;
  2820. col.iSubItem = iSubItem;
  2821. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2822. return E_FAIL;
  2823. iSubItem++;
  2824. // Add a bogus column so SetColumnWidth doesn't do strange
  2825. // things with the last real column
  2826. col.fmt = LVCFMT_RIGHT;
  2827. col.pszText = TEXT("");
  2828. col.iSubItem = iSubItem;
  2829. if (-1 == ListView_InsertColumn(hwndList, iSubItem, &col))
  2830. return E_FAIL;
  2831. iSubItem++;
  2832. return S_OK;
  2833. }
  2834. /****************************************************************************
  2835. *
  2836. * AddMusicPortInfo
  2837. *
  2838. ****************************************************************************/
  2839. HRESULT AddMusicPortInfo(HWND hwndList, MusicInfo* pMusicInfo)
  2840. {
  2841. MusicPort* pMusicPort;
  2842. LV_ITEM item;
  2843. LONG iSubItem;
  2844. TCHAR sz[MAX_PATH];
  2845. for (pMusicPort = pMusicInfo->m_pMusicPortFirst; pMusicPort != NULL;
  2846. pMusicPort = pMusicPort->m_pMusicPortNext)
  2847. {
  2848. iSubItem = 0;
  2849. item.mask = LVIF_TEXT | LVIF_STATE;
  2850. item.iItem = ListView_GetItemCount(hwndList);
  2851. item.stateMask = 0xffff;
  2852. item.cchTextMax = 100;
  2853. /* if (pMusicPortInfo->m_bProblem)
  2854. item.state = (1 << 12);
  2855. else
  2856. */ item.state = 0;
  2857. item.iSubItem = iSubItem++;
  2858. item.pszText = pMusicPort->m_szDescription;
  2859. if (-1 == ListView_InsertItem(hwndList, &item))
  2860. return E_FAIL;
  2861. item.mask = LVIF_TEXT;
  2862. item.iSubItem = iSubItem++;
  2863. LoadString(NULL, pMusicPort->m_bSoftware ? IDS_SOFTWARE : IDS_HARDWARE, sz, MAX_PATH);
  2864. item.pszText = sz;
  2865. if (FALSE == ListView_SetItem(hwndList, &item))
  2866. return E_FAIL;
  2867. item.iSubItem = iSubItem++;
  2868. LoadString(NULL, pMusicPort->m_bKernelMode ? IDS_YES : IDS_NO, sz, MAX_PATH);
  2869. item.pszText = sz;
  2870. if (FALSE == ListView_SetItem(hwndList, &item))
  2871. return E_FAIL;
  2872. item.iSubItem = iSubItem++;
  2873. LoadString(NULL, pMusicPort->m_bOutputPort ? IDS_OUTPUT : IDS_INPUT, sz, MAX_PATH);
  2874. item.pszText = sz;
  2875. if (FALSE == ListView_SetItem(hwndList, &item))
  2876. return E_FAIL;
  2877. item.iSubItem = iSubItem++;
  2878. LoadString(NULL, pMusicPort->m_bUsesDLS ? IDS_YES : IDS_NO, sz, MAX_PATH);
  2879. item.pszText = sz;
  2880. if (FALSE == ListView_SetItem(hwndList, &item))
  2881. return E_FAIL;
  2882. item.iSubItem = iSubItem++;
  2883. LoadString(NULL, pMusicPort->m_bExternal ? IDS_YES : IDS_NO, sz, MAX_PATH);
  2884. item.pszText = sz;
  2885. if (FALSE == ListView_SetItem(hwndList, &item))
  2886. return E_FAIL;
  2887. item.iSubItem = iSubItem++;
  2888. LoadString(NULL, pMusicPort->m_bDefaultPort ? IDS_YES : IDS_NO, sz, MAX_PATH);
  2889. item.pszText = sz;
  2890. if (FALSE == ListView_SetItem(hwndList, &item))
  2891. return E_FAIL;
  2892. }
  2893. return S_OK;
  2894. }
  2895. /****************************************************************************
  2896. *
  2897. * ScanSystem
  2898. *
  2899. ****************************************************************************/
  2900. HRESULT ScanSystem(VOID)
  2901. {
  2902. HRESULT hr;
  2903. TCHAR szPath[MAX_PATH];
  2904. // ******* GetComponentFiles (SI:2) ********
  2905. if( s_bUseSystemInfo )
  2906. {
  2907. s_bUseSystemInfo = QueryCrashProtection( DXD_IN_SI_KEY, DXD_IN_SI_VALUE, IDS_SI, 2 );
  2908. if( s_bUseSystemInfo )
  2909. {
  2910. EnterCrashProtection( DXD_IN_SI_KEY, DXD_IN_SI_VALUE, 2 );
  2911. // ******* GetComponentFiles in Windows Dir ********
  2912. // First, check for DirectX files incorrectly stored in the Windows folder:
  2913. if( GetWindowsDirectory(szPath, MAX_PATH) == 0 )
  2914. return E_FAIL;
  2915. if (FAILED(hr = GetComponentFiles(szPath, &s_pDxWinComponentsFileInfoFirst, TRUE, IDS_DXGRAPHICS_COMPONENTFILES)))
  2916. ReportError(IDS_COMPONENTFILESPROBLEM, hr);
  2917. if (FAILED(hr = GetComponentFiles(szPath, &s_pDxWinComponentsFileInfoFirst, TRUE, IDS_DPLAY_COMPONENTFILES)))
  2918. ReportError(IDS_COMPONENTFILESPROBLEM, hr);
  2919. if (FAILED(hr = GetComponentFiles(szPath, &s_pDxWinComponentsFileInfoFirst, TRUE, IDS_DINPUT_COMPONENTFILES)))
  2920. ReportError(IDS_COMPONENTFILESPROBLEM, hr);
  2921. if (FAILED(hr = GetComponentFiles(szPath, &s_pDxWinComponentsFileInfoFirst, TRUE, IDS_DXAUDIO_COMPONENTFILES)))
  2922. ReportError(IDS_COMPONENTFILESPROBLEM, hr);
  2923. if (FAILED(hr = GetComponentFiles(szPath, &s_pDxWinComponentsFileInfoFirst, TRUE, IDS_DXMISC_COMPONENTFILES)))
  2924. ReportError(IDS_COMPONENTFILESPROBLEM, hr);
  2925. if (FAILED(hr = GetComponentFiles(szPath, &s_pDxWinComponentsFileInfoFirst, TRUE, IDS_BDA_COMPONENTFILES)))
  2926. ReportError(IDS_BDA_COMPONENTFILES, hr);
  2927. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  2928. // ******* GetComponentFiles in Sys Dir ********
  2929. GetSystemDirectory(szPath, MAX_PATH);
  2930. if (FAILED(hr = GetComponentFiles(szPath, &s_pDxComponentsFileInfoFirst, FALSE, IDS_DXGRAPHICS_COMPONENTFILES)))
  2931. ReportError(IDS_COMPONENTFILESPROBLEM, hr);
  2932. if (FAILED(hr = GetComponentFiles(szPath, &s_pDxComponentsFileInfoFirst, FALSE, IDS_DPLAY_COMPONENTFILES)))
  2933. ReportError(IDS_COMPONENTFILESPROBLEM, hr);
  2934. if (FAILED(hr = GetComponentFiles(szPath, &s_pDxComponentsFileInfoFirst, FALSE, IDS_DINPUT_COMPONENTFILES)))
  2935. ReportError(IDS_COMPONENTFILESPROBLEM, hr);
  2936. if (FAILED(hr = GetComponentFiles(szPath, &s_pDxComponentsFileInfoFirst, FALSE, IDS_DXAUDIO_COMPONENTFILES)))
  2937. ReportError(IDS_COMPONENTFILESPROBLEM, hr);
  2938. if (FAILED(hr = GetComponentFiles(szPath, &s_pDxComponentsFileInfoFirst, FALSE, IDS_DXMISC_COMPONENTFILES)))
  2939. ReportError(IDS_COMPONENTFILESPROBLEM, hr);
  2940. if (GetDxSetupFolder(szPath))
  2941. {
  2942. if (FAILED(hr = GetComponentFiles(szPath, &s_pDxComponentsFileInfoFirst, FALSE, IDS_DXSETUP_COMPONENTFILES)))
  2943. ReportError(IDS_COMPONENTFILESPROBLEM, hr);
  2944. }
  2945. GetSystemDirectory(szPath, MAX_PATH);
  2946. if (FAILED(hr = GetComponentFiles(szPath, &s_pDxComponentsFileInfoFirst, FALSE, IDS_DXMEDIA_COMPONENTFILES)))
  2947. ReportError(IDS_COMPONENTFILESPROBLEM, hr);
  2948. if (FAILED(hr = GetComponentFiles(szPath, &s_pDxComponentsFileInfoFirst, FALSE, IDS_BDA_COMPONENTFILES)))
  2949. ReportError(IDS_BDA_COMPONENTFILES, hr);
  2950. LeaveCrashProtection( DXD_IN_SI_KEY, DXD_IN_SI_VALUE, 2 );
  2951. }
  2952. }
  2953. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  2954. // Stop if the UI thread is gone
  2955. if( s_hUIThread != NULL && WAIT_TIMEOUT != WaitForSingleObject( s_hUIThread, 0 ) )
  2956. return S_FALSE;
  2957. // ******* GetExtraDisplayInfo (DD:2) ********
  2958. if( s_bUseDisplay )
  2959. {
  2960. s_bUseDisplay = QueryCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, IDS_DD, 2 );
  2961. if( s_bUseDisplay )
  2962. {
  2963. EnterCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 2 );
  2964. if (FAILED(hr = GetExtraDisplayInfo(s_pDisplayInfoFirst)))
  2965. ReportError(IDS_NOEXTRADISPLAYINFO, hr);
  2966. LeaveCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 2 );
  2967. }
  2968. }
  2969. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  2970. // Stop if the UI thread is gone
  2971. if( s_hUIThread != NULL && WAIT_TIMEOUT != WaitForSingleObject( s_hUIThread, 0 ) )
  2972. return S_FALSE;
  2973. // ******* GetDDrawDisplayInfo (DD:3) ********
  2974. if( s_bUseDisplay )
  2975. {
  2976. s_bUseDisplay = QueryCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, IDS_DD, 3 );
  2977. if( !s_bGUI )
  2978. {
  2979. // If there's no gui, then check to see if we are 16 or less colors
  2980. // If we are then don't use DirectDraw otherwise it will pop up a warning box
  2981. HDC hDC = GetDC( NULL );
  2982. if( hDC )
  2983. {
  2984. int nBitsPerPixel = GetDeviceCaps( hDC, BITSPIXEL );
  2985. ReleaseDC( NULL, hDC );
  2986. if( nBitsPerPixel < 8 )
  2987. s_bUseDisplay = FALSE;
  2988. }
  2989. }
  2990. if( s_bUseDisplay )
  2991. {
  2992. EnterCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 3 );
  2993. if(FAILED(hr = GetDDrawDisplayInfo(s_pDisplayInfoFirst)))
  2994. ReportError(IDS_NOEXTRADISPLAYINFO, hr);
  2995. LeaveCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 3 );
  2996. }
  2997. }
  2998. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  2999. // Stop if the UI thread is gone
  3000. if( s_hUIThread != NULL && WAIT_TIMEOUT != WaitForSingleObject( s_hUIThread, 0 ) )
  3001. return S_FALSE;
  3002. // ******* GetExtraSoundInfo (DS:2) ********
  3003. if( s_bUseDSound )
  3004. {
  3005. s_bUseDSound = QueryCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, IDS_DS, 2 );
  3006. if( s_bUseDSound )
  3007. {
  3008. EnterCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 2 );
  3009. if (FAILED(hr = GetExtraSoundInfo(s_pSoundInfoFirst)))
  3010. ReportError(IDS_NOEXTRASOUNDINFO, hr);
  3011. LeaveCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 2 );
  3012. }
  3013. }
  3014. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  3015. // Stop if the UI thread is gone
  3016. if( s_hUIThread != NULL && WAIT_TIMEOUT != WaitForSingleObject( s_hUIThread, 0 ) )
  3017. return S_FALSE;
  3018. // ******* GetDSSoundInfo (DS:3) ********
  3019. if( s_bUseDSound )
  3020. {
  3021. s_bUseDSound = QueryCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, IDS_DS, 3 );
  3022. if( s_bUseDSound )
  3023. {
  3024. EnterCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 3 );
  3025. if (FAILED(hr = GetDSSoundInfo(s_pSoundInfoFirst)))
  3026. ReportError(IDS_NOEXTRASOUNDINFO, hr);
  3027. LeaveCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 3 );
  3028. }
  3029. }
  3030. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  3031. // Stop if the UI thread is gone
  3032. if( s_hUIThread != NULL && WAIT_TIMEOUT != WaitForSingleObject( s_hUIThread, 0 ) )
  3033. return S_FALSE;
  3034. // ******* GetExtraMusicInfo (DM:2) *******
  3035. if( s_bUseDMusic )
  3036. {
  3037. if (s_pMusicInfo != NULL && s_pMusicInfo->m_bDMusicInstalled)
  3038. {
  3039. s_bUseDMusic = QueryCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, IDS_DM, 2 );
  3040. if( s_bUseDMusic )
  3041. {
  3042. EnterCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, 2 );
  3043. if (FAILED(hr = GetExtraMusicInfo(s_pMusicInfo)))
  3044. ReportError(IDS_NOBASICMUSICINFO, hr);
  3045. LeaveCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, 2 );
  3046. }
  3047. if (s_pMusicInfo->m_pMusicPortFirst != NULL)
  3048. s_pMusicInfo->m_guidMusicPortTest = s_pMusicInfo->m_pMusicPortFirst->m_guid;
  3049. }
  3050. }
  3051. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  3052. // Stop if the UI thread is gone
  3053. if( s_hUIThread != NULL && WAIT_TIMEOUT != WaitForSingleObject( s_hUIThread, 0 ) )
  3054. return S_FALSE;
  3055. // ******* GetInputInfo (DI:1) ********
  3056. if( s_bUseDInput )
  3057. {
  3058. s_bUseDInput = QueryCrashProtection( DXD_IN_DI_KEY, DXD_IN_DI_VALUE, IDS_DI, 1 );
  3059. if( s_bUseDInput )
  3060. {
  3061. EnterCrashProtection( DXD_IN_DI_KEY, DXD_IN_DI_VALUE, 1 );
  3062. if (FAILED(hr = GetInputInfo(&s_pInputInfo)))
  3063. ReportError(IDS_NOINPUTINFO, hr);
  3064. LeaveCrashProtection( DXD_IN_DI_KEY, DXD_IN_DI_VALUE, 1 );
  3065. }
  3066. }
  3067. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  3068. // Stop if the UI thread is gone
  3069. if( s_hUIThread != NULL && WAIT_TIMEOUT != WaitForSingleObject( s_hUIThread, 0 ) )
  3070. return S_FALSE;
  3071. // ******* GetInputDriverInfo (DI:2) ********
  3072. if( s_bUseDInput )
  3073. {
  3074. s_bUseDInput = QueryCrashProtection( DXD_IN_DI_KEY, DXD_IN_DI_VALUE, IDS_DI, 2 );
  3075. if( s_bUseDInput )
  3076. {
  3077. EnterCrashProtection( DXD_IN_DI_KEY, DXD_IN_DI_VALUE, 2 );
  3078. if (FAILED(hr = GetInputDriverInfo(s_pInputInfo)))
  3079. ReportError(IDS_NOINPUTDRIVERINFO, hr);
  3080. LeaveCrashProtection( DXD_IN_DI_KEY, DXD_IN_DI_VALUE, 2 );
  3081. }
  3082. }
  3083. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  3084. // Stop if the UI thread is gone
  3085. if( s_hUIThread != NULL && WAIT_TIMEOUT != WaitForSingleObject( s_hUIThread, 0 ) )
  3086. return S_FALSE;
  3087. // ******* GetNetInfo (DP:1) ********
  3088. if( s_bUseDPlay )
  3089. {
  3090. s_bUseDPlay = QueryCrashProtection( DXD_IN_DP_KEY, DXD_IN_DP_VALUE, IDS_DP, 1 );
  3091. if( s_bUseDPlay )
  3092. {
  3093. EnterCrashProtection( DXD_IN_DP_KEY, DXD_IN_DP_VALUE, 1 );
  3094. if (FAILED(hr = GetNetInfo(&s_sysInfo, &s_pNetInfo)))
  3095. ReportError(IDS_NONETINFO, hr);
  3096. LeaveCrashProtection( DXD_IN_DP_KEY, DXD_IN_DP_VALUE, 1 );
  3097. }
  3098. }
  3099. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  3100. // Stop if the UI thread is gone
  3101. if( s_hUIThread != NULL && WAIT_TIMEOUT != WaitForSingleObject( s_hUIThread, 0 ) )
  3102. return S_FALSE;
  3103. // ******* GetBasicShowInfo (SI:3) ********
  3104. if( s_bUseDShow )
  3105. {
  3106. s_bUseDShow = QueryCrashProtection( DXD_IN_SI_KEY, DXD_IN_SI_VALUE, IDS_SI, 3 );
  3107. if( s_bUseDShow )
  3108. {
  3109. EnterCrashProtection( DXD_IN_SI_KEY, DXD_IN_SI_VALUE, 3 );
  3110. if (FAILED(hr = GetBasicShowInfo(&s_pShowInfo)))
  3111. ReportError(IDS_COMPONENTFILESPROBLEM, hr);
  3112. LeaveCrashProtection( DXD_IN_SI_KEY, DXD_IN_SI_VALUE, 3 );
  3113. }
  3114. }
  3115. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  3116. // Stop if the UI thread is gone
  3117. if( s_hUIThread != NULL && WAIT_TIMEOUT != WaitForSingleObject( s_hUIThread, 0 ) )
  3118. return S_FALSE;
  3119. // ******* DiagnoseDxFiles ********
  3120. DiagnoseDxFiles(&s_sysInfo, s_pDxComponentsFileInfoFirst,
  3121. s_pDxWinComponentsFileInfoFirst);
  3122. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  3123. // ******* DiagnoseDisplay ********
  3124. DiagnoseDisplay(&s_sysInfo, s_pDisplayInfoFirst);
  3125. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  3126. // ******* DiagnoseSound ********
  3127. DiagnoseSound(s_pSoundInfoFirst);
  3128. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  3129. // ******* DiagnoseInput ********
  3130. DiagnoseInput(&s_sysInfo, s_pInputInfo);
  3131. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  3132. // ******* DiagnoseMusic ********
  3133. DiagnoseMusic(&s_sysInfo, s_pMusicInfo);
  3134. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  3135. // ******* DiagnoseNetInfo ********
  3136. DiagnoseNetInfo(&s_sysInfo, s_pNetInfo);
  3137. SendMessage( s_hwndMain, WM_APP_PROGRESS, 0, 0 );
  3138. return S_OK;
  3139. }
  3140. /****************************************************************************
  3141. *
  3142. * SaveInfo
  3143. *
  3144. ****************************************************************************/
  3145. VOID SaveInfo(VOID)
  3146. {
  3147. HRESULT hr;
  3148. OPENFILENAME ofn;
  3149. TCHAR szFile[MAX_PATH];
  3150. TCHAR szFilter[MAX_PATH];
  3151. TCHAR szExt[MAX_PATH];
  3152. TCHAR* pch = NULL;
  3153. LoadString(NULL, IDS_FILTER, szFilter, MAX_PATH);
  3154. // Filter strings are weird because they contain nulls.
  3155. // The string loaded from a resource has # where nulls
  3156. // should be inserted.
  3157. for (pch = szFilter; *pch != TEXT('\0'); pch++)
  3158. {
  3159. if (*pch == TEXT('#'))
  3160. *pch = TEXT('\0');
  3161. }
  3162. LoadString(NULL, IDS_DEFAULTFILENAME, szFile, MAX_PATH);
  3163. LoadString(NULL, IDS_DEFAULTEXT, szExt, MAX_PATH);
  3164. ZeroMemory(&ofn, sizeof(ofn));
  3165. ofn.lStructSize = sizeof(ofn);
  3166. ofn.hwndOwner = s_hwndMain;
  3167. ofn.lpstrFilter = szFilter;
  3168. ofn.lpstrFile = szFile;
  3169. ofn.nMaxFile = MAX_PATH;
  3170. ofn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
  3171. ofn.lpstrDefExt = szExt;
  3172. TCHAR szInitialPath[MAX_PATH];
  3173. if( FALSE == GetTxtPath( szInitialPath ) )
  3174. ofn.lpstrInitialDir = NULL;
  3175. else
  3176. ofn.lpstrInitialDir = szInitialPath;
  3177. if (GetSaveFileName(&ofn))
  3178. {
  3179. lstrcpy( szInitialPath, ofn.lpstrFile );
  3180. TCHAR* strLastSlash = _tcsrchr(szInitialPath, '\\' );
  3181. if( NULL != strLastSlash )
  3182. {
  3183. *strLastSlash = 0;
  3184. SetTxtPath( szInitialPath );
  3185. }
  3186. if (FAILED(hr = SaveAllInfo(ofn.lpstrFile, &s_sysInfo,
  3187. s_pDxWinComponentsFileInfoFirst, s_pDxComponentsFileInfoFirst,
  3188. s_pDisplayInfoFirst, s_pSoundInfoFirst, s_pMusicInfo,
  3189. s_pInputInfo, s_pNetInfo, s_pShowInfo)))
  3190. {
  3191. }
  3192. }
  3193. }
  3194. /****************************************************************************
  3195. *
  3196. * ToggleDDAccel
  3197. *
  3198. ****************************************************************************/
  3199. VOID ToggleDDAccel(VOID)
  3200. {
  3201. HRESULT hr;
  3202. TCHAR szTitle[MAX_PATH];
  3203. TCHAR szMessage[MAX_PATH];
  3204. BOOL bEnabled = IsDDHWAccelEnabled();
  3205. HKEY hkey;
  3206. DWORD dwData;
  3207. LoadString(NULL, IDS_APPFULLNAME, szTitle, MAX_PATH);
  3208. if (bEnabled)
  3209. LoadString(NULL, IDS_DISABLEDDWARNING, szMessage, MAX_PATH);
  3210. else
  3211. LoadString(NULL, IDS_ENABLEDDWARNING, szMessage, MAX_PATH);
  3212. if (IDOK == MessageBox(s_hwndMain, szMessage, szTitle, MB_OKCANCEL))
  3213. {
  3214. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  3215. TEXT("SOFTWARE\\Microsoft\\DirectDraw"), 0, KEY_ALL_ACCESS, &hkey))
  3216. {
  3217. if (bEnabled) // if acceleration enabled
  3218. dwData = TRUE; // force emulation
  3219. else
  3220. dwData = FALSE; // disable emulation
  3221. if (ERROR_SUCCESS != RegSetValueEx(hkey, TEXT("EmulationOnly"), NULL,
  3222. REG_DWORD, (BYTE *)&dwData, sizeof(dwData)))
  3223. {
  3224. // TODO: report error
  3225. RegCloseKey(hkey);
  3226. return;
  3227. }
  3228. RegCloseKey(hkey);
  3229. }
  3230. else
  3231. {
  3232. // TODO: report error
  3233. return;
  3234. }
  3235. }
  3236. // update all DisplayInfo to reflect new state:
  3237. // ******* GetExtraDisplayInfo (DD:2) ********
  3238. if( s_bUseDisplay )
  3239. {
  3240. s_bUseDisplay = QueryCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, IDS_DD, 2 );
  3241. if( s_bUseDisplay )
  3242. {
  3243. EnterCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 2 );
  3244. if (FAILED(hr = GetExtraDisplayInfo(s_pDisplayInfoFirst)))
  3245. ReportError(IDS_NOEXTRADISPLAYINFO, hr);
  3246. LeaveCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 2 );
  3247. }
  3248. }
  3249. // ******* GetDDrawDisplayInfo (DD:3) ********
  3250. if( s_bUseDisplay )
  3251. {
  3252. s_bUseDisplay = QueryCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, IDS_DD, 3 );
  3253. if( s_bUseDisplay )
  3254. {
  3255. EnterCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 3 );
  3256. if(FAILED(hr = GetDDrawDisplayInfo(s_pDisplayInfoFirst)))
  3257. ReportError(IDS_NOEXTRADISPLAYINFO, hr);
  3258. LeaveCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 3 );
  3259. }
  3260. }
  3261. SetupDisplayPage(s_lwCurPage - s_iPageDisplayFirst); // refresh page
  3262. }
  3263. /****************************************************************************
  3264. *
  3265. * ToggleD3DAccel
  3266. *
  3267. ****************************************************************************/
  3268. VOID ToggleD3DAccel(VOID)
  3269. {
  3270. TCHAR szTitle[MAX_PATH];
  3271. TCHAR szMessage[MAX_PATH];
  3272. BOOL bEnabled = IsD3DHWAccelEnabled();
  3273. HKEY hkey;
  3274. DWORD dwData;
  3275. LoadString(NULL, IDS_APPFULLNAME, szTitle, MAX_PATH);
  3276. if (bEnabled)
  3277. LoadString(NULL, IDS_DISABLED3DWARNING, szMessage, MAX_PATH);
  3278. else
  3279. LoadString(NULL, IDS_ENABLED3DWARNING, szMessage, MAX_PATH);
  3280. if (IDOK == MessageBox(s_hwndMain, szMessage, szTitle, MB_OKCANCEL))
  3281. {
  3282. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  3283. TEXT("SOFTWARE\\Microsoft\\Direct3D\\Drivers"), 0, KEY_WRITE, &hkey))
  3284. {
  3285. if (bEnabled) // if acceleration enabled
  3286. dwData = TRUE; // force emulation
  3287. else
  3288. dwData = FALSE; // disable emulation
  3289. if (ERROR_SUCCESS != RegSetValueEx(hkey, TEXT("SoftwareOnly"), NULL,
  3290. REG_DWORD, (BYTE *)&dwData, sizeof(dwData)))
  3291. {
  3292. // TODO: report error
  3293. RegCloseKey(hkey);
  3294. return;
  3295. }
  3296. RegCloseKey(hkey);
  3297. // update all DisplayInfo to reflect new state:
  3298. DisplayInfo* pDisplayInfo;
  3299. for (pDisplayInfo = s_pDisplayInfoFirst; pDisplayInfo != NULL;
  3300. pDisplayInfo = pDisplayInfo->m_pDisplayInfoNext)
  3301. {
  3302. pDisplayInfo->m_b3DAccelerationEnabled = !bEnabled;
  3303. }
  3304. }
  3305. else
  3306. {
  3307. // TODO: report error
  3308. return;
  3309. }
  3310. }
  3311. SetupDisplayPage(s_lwCurPage - s_iPageDisplayFirst); // refresh page
  3312. }
  3313. /****************************************************************************
  3314. *
  3315. * ToggleAGPSupport
  3316. *
  3317. ****************************************************************************/
  3318. VOID ToggleAGPSupport(VOID)
  3319. {
  3320. HRESULT hr;
  3321. TCHAR szTitle[MAX_PATH];
  3322. TCHAR szMessage[MAX_PATH];
  3323. BOOL bEnabled = IsAGPEnabled();
  3324. HKEY hkey;
  3325. DWORD dwData;
  3326. LoadString(NULL, IDS_APPFULLNAME, szTitle, MAX_PATH);
  3327. if (bEnabled)
  3328. LoadString(NULL, IDS_DISABLEAGPWARNING, szMessage, MAX_PATH);
  3329. else
  3330. LoadString(NULL, IDS_ENABLEAGPWARNING, szMessage, MAX_PATH);
  3331. if (IDOK == MessageBox(s_hwndMain, szMessage, szTitle, MB_OKCANCEL))
  3332. {
  3333. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  3334. TEXT("SOFTWARE\\Microsoft\\DirectDraw"), 0, KEY_WRITE, &hkey))
  3335. {
  3336. if (bEnabled) // if AGP enabled
  3337. dwData = TRUE; // disable
  3338. else
  3339. dwData = FALSE; // enable
  3340. if (ERROR_SUCCESS != RegSetValueEx(hkey, TEXT("DisableAGPSupport"), NULL,
  3341. REG_DWORD, (BYTE *)&dwData, sizeof(dwData)))
  3342. {
  3343. // TODO: report error
  3344. RegCloseKey(hkey);
  3345. return;
  3346. }
  3347. RegCloseKey(hkey);
  3348. // update all DisplayInfo to reflect new state:
  3349. DisplayInfo* pDisplayInfo;
  3350. for (pDisplayInfo = s_pDisplayInfoFirst; pDisplayInfo != NULL;
  3351. pDisplayInfo = pDisplayInfo->m_pDisplayInfoNext)
  3352. {
  3353. pDisplayInfo->m_bAGPEnabled = !bEnabled;
  3354. }
  3355. }
  3356. else
  3357. {
  3358. // TODO: report error
  3359. return;
  3360. }
  3361. }
  3362. // ******* GetDDrawDisplayInfo (DD:3) ********
  3363. if( s_bUseDisplay )
  3364. {
  3365. s_bUseDisplay = QueryCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, IDS_DD, 3 );
  3366. if( s_bUseDisplay )
  3367. {
  3368. EnterCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 3 );
  3369. if(FAILED(hr = GetDDrawDisplayInfo(s_pDisplayInfoFirst)))
  3370. ReportError(IDS_NOEXTRADISPLAYINFO, hr);
  3371. LeaveCrashProtection( DXD_IN_DD_KEY, DXD_IN_DD_VALUE, 3 );
  3372. }
  3373. }
  3374. SetupDisplayPage(s_lwCurPage - s_iPageDisplayFirst); // refresh page
  3375. }
  3376. /****************************************************************************
  3377. *
  3378. * ToggleDMAccel
  3379. *
  3380. ****************************************************************************/
  3381. VOID ToggleDMAccel(VOID)
  3382. {
  3383. HRESULT hr;
  3384. TCHAR szTitle[MAX_PATH];
  3385. TCHAR szMessage[MAX_PATH];
  3386. BOOL bEnabled = s_pMusicInfo->m_bAccelerationEnabled;
  3387. HKEY hkey;
  3388. DWORD dwData;
  3389. LoadString(NULL, IDS_APPFULLNAME, szTitle, MAX_PATH);
  3390. if (bEnabled)
  3391. LoadString(NULL, IDS_DISABLEDMWARNING, szMessage, MAX_PATH);
  3392. else
  3393. LoadString(NULL, IDS_ENABLEDMWARNING, szMessage, MAX_PATH);
  3394. if (IDOK == MessageBox(s_hwndMain, szMessage, szTitle, MB_OKCANCEL))
  3395. {
  3396. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  3397. TEXT("SOFTWARE\\Microsoft\\DirectMusic"), 0, KEY_ALL_ACCESS, &hkey))
  3398. {
  3399. if (bEnabled) // if acceleration enabled
  3400. {
  3401. dwData = TRUE; // force emulation
  3402. if (ERROR_SUCCESS != RegSetValueEx(hkey, TEXT("DisableHWAcceleration"), NULL,
  3403. REG_DWORD, (BYTE *)&dwData, sizeof(dwData)))
  3404. {
  3405. // TODO: report error
  3406. RegCloseKey(hkey);
  3407. return;
  3408. }
  3409. }
  3410. else
  3411. {
  3412. if (ERROR_SUCCESS != RegDeleteValue( hkey, TEXT("DisableHWAcceleration") ))
  3413. {
  3414. // TODO: report error
  3415. RegCloseKey(hkey);
  3416. return;
  3417. }
  3418. }
  3419. RegCloseKey(hkey);
  3420. }
  3421. else
  3422. {
  3423. // TODO: report error
  3424. return;
  3425. }
  3426. }
  3427. // update all MusicInfo to reflect new state:
  3428. if (s_pMusicInfo != NULL)
  3429. DestroyMusicInfo(s_pMusicInfo);
  3430. // ******* GetBasicMusicInfo (DM:1) ********
  3431. if( s_bUseDMusic )
  3432. {
  3433. s_bUseDMusic = QueryCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, IDS_DM, 1 );
  3434. if( s_bUseDMusic )
  3435. {
  3436. EnterCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, 1 );
  3437. if (FAILED(hr = GetBasicMusicInfo(&s_pMusicInfo)))
  3438. ReportError(IDS_NOBASICMUSICINFO, hr);
  3439. LeaveCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, 1 );
  3440. }
  3441. }
  3442. // ******* GetExtraMusicInfo (DM:2) *******
  3443. if( s_bUseDMusic )
  3444. {
  3445. s_bUseDMusic = QueryCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, IDS_DM, 2 );
  3446. if( s_bUseDMusic )
  3447. {
  3448. EnterCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, 2 );
  3449. if (FAILED(hr = GetExtraMusicInfo(s_pMusicInfo)))
  3450. ReportError(IDS_NOBASICMUSICINFO, hr);
  3451. LeaveCrashProtection( DXD_IN_DM_KEY, DXD_IN_DM_VALUE, 2 );
  3452. }
  3453. }
  3454. if (s_pMusicInfo->m_pMusicPortFirst != NULL)
  3455. s_pMusicInfo->m_guidMusicPortTest = s_pMusicInfo->m_pMusicPortFirst->m_guid;
  3456. SetupMusicPage(); // refresh page
  3457. }
  3458. /****************************************************************************
  3459. *
  3460. * OverrideDDRefresh
  3461. *
  3462. ****************************************************************************/
  3463. VOID OverrideDDRefresh(VOID)
  3464. {
  3465. HINSTANCE hinst = (HINSTANCE)GetWindowLongPtr(s_hwndMain, GWLP_HINSTANCE);
  3466. DialogBox(hinst, MAKEINTRESOURCE(IDD_OVERRIDEDD), s_hwndMain,
  3467. OverrideRefreshDialogProc);
  3468. }
  3469. /****************************************************************************
  3470. *
  3471. * OverrideRefreshDialogProc
  3472. *
  3473. ****************************************************************************/
  3474. INT_PTR CALLBACK OverrideRefreshDialogProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
  3475. {
  3476. HWND hwndTabs = GetDlgItem(hwnd, IDC_TAB);
  3477. HKEY hkey;
  3478. ULONG ulType = 0;
  3479. DWORD dwRefresh;
  3480. DWORD cbData;
  3481. switch (msg)
  3482. {
  3483. case WM_INITDIALOG:
  3484. dwRefresh = 0;
  3485. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  3486. TEXT("Software\\Microsoft\\DirectDraw"), 0, KEY_READ, &hkey))
  3487. {
  3488. cbData = sizeof(DWORD);
  3489. RegQueryValueEx(hkey, TEXT("ForceRefreshRate"), 0, &ulType, (LPBYTE)&dwRefresh, &cbData);
  3490. RegCloseKey(hkey);
  3491. }
  3492. if (dwRefresh == 0)
  3493. {
  3494. CheckRadioButton(hwnd, IDC_DEFAULTREFRESH, IDC_OVERRIDEREFRESH, IDC_DEFAULTREFRESH);
  3495. }
  3496. else
  3497. {
  3498. CheckRadioButton(hwnd, IDC_DEFAULTREFRESH, IDC_OVERRIDEREFRESH, IDC_OVERRIDEREFRESH);
  3499. SetDlgItemInt(hwnd, IDC_OVERRIDEREFRESHVALUE, dwRefresh, FALSE);
  3500. }
  3501. return TRUE;
  3502. case WM_COMMAND:
  3503. {
  3504. WORD wID = LOWORD(wparam);
  3505. BOOL bDontEnd = FALSE;
  3506. switch(wID)
  3507. {
  3508. case IDOK:
  3509. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  3510. TEXT("Software\\Microsoft\\DirectDraw"), 0, KEY_ALL_ACCESS, &hkey))
  3511. {
  3512. DWORD dwButtonState;
  3513. dwButtonState = (DWORD)SendMessage(GetDlgItem(hwnd, IDC_DEFAULTREFRESH), BM_GETCHECK, 0, 0);
  3514. if (dwButtonState == BST_CHECKED)
  3515. {
  3516. RegDeleteValue(hkey, TEXT("ForceRefreshRate"));
  3517. }
  3518. else
  3519. {
  3520. BOOL bTranslated;
  3521. UINT ui = GetDlgItemInt(hwnd, IDC_OVERRIDEREFRESHVALUE, &bTranslated, TRUE);
  3522. if (bTranslated && ui >= 40 && ui <= 120)
  3523. RegSetValueEx(hkey, TEXT("ForceRefreshRate"), 0, REG_DWORD, (LPBYTE)&ui, sizeof(DWORD));
  3524. else
  3525. {
  3526. TCHAR sz[MAX_PATH];
  3527. TCHAR szTitle[MAX_PATH];
  3528. SetDlgItemText(hwnd, IDC_OVERRIDEREFRESHVALUE, TEXT(""));
  3529. CheckRadioButton(hwnd, IDC_DEFAULTREFRESH, IDC_OVERRIDEREFRESH, IDC_DEFAULTREFRESH);
  3530. LoadString(NULL, IDS_BADREFRESHVALUE, sz, MAX_PATH);
  3531. LoadString(NULL, IDS_APPFULLNAME, szTitle, MAX_PATH);
  3532. MessageBox(hwnd, sz, szTitle, MB_OK);
  3533. bDontEnd = TRUE;
  3534. }
  3535. }
  3536. RegCloseKey(hkey);
  3537. }
  3538. else
  3539. {
  3540. }
  3541. if (!bDontEnd)
  3542. EndDialog(hwnd, IDOK);
  3543. break;
  3544. case IDCANCEL:
  3545. EndDialog(hwnd, IDCANCEL);
  3546. break;
  3547. case IDC_OVERRIDEREFRESHVALUE:
  3548. if (HIWORD(wparam) == EN_SETFOCUS)
  3549. {
  3550. CheckRadioButton(hwnd, IDC_DEFAULTREFRESH, IDC_OVERRIDEREFRESH, IDC_OVERRIDEREFRESH);
  3551. }
  3552. else if (HIWORD(wparam) == EN_KILLFOCUS)
  3553. {
  3554. TCHAR szEdit[MAX_PATH];
  3555. BOOL bTranslated;
  3556. if (GetDlgItemText(hwnd, IDC_OVERRIDEREFRESHVALUE, szEdit, 100) == 0)
  3557. {
  3558. CheckRadioButton(hwnd, IDC_DEFAULTREFRESH, IDC_OVERRIDEREFRESH, IDC_DEFAULTREFRESH);
  3559. }
  3560. else
  3561. {
  3562. UINT ui = GetDlgItemInt(hwnd, IDC_OVERRIDEREFRESHVALUE, &bTranslated, TRUE);
  3563. if (!bTranslated || ui < 40 || ui > 120)
  3564. {
  3565. TCHAR sz[MAX_PATH];
  3566. TCHAR szTitle[MAX_PATH];
  3567. LoadString(NULL, IDS_BADREFRESHVALUE, sz, MAX_PATH);
  3568. LoadString(NULL, IDS_APPFULLNAME, szTitle, MAX_PATH);
  3569. MessageBox(hwnd, sz, szTitle, MB_OK);
  3570. SetDlgItemText(hwnd, IDC_OVERRIDEREFRESHVALUE, TEXT(""));
  3571. CheckRadioButton(hwnd, IDC_DEFAULTREFRESH, IDC_OVERRIDEREFRESH, IDC_DEFAULTREFRESH);
  3572. }
  3573. }
  3574. }
  3575. break;
  3576. }
  3577. }
  3578. return TRUE;
  3579. }
  3580. return FALSE;
  3581. }
  3582. /****************************************************************************
  3583. *
  3584. * ShowHelp - Look for dxdiag.chm in <windows>\help first, then try the
  3585. * same dir as the exe.
  3586. *
  3587. ****************************************************************************/
  3588. VOID ShowHelp(VOID)
  3589. {
  3590. TCHAR szHelpDir[MAX_PATH];
  3591. TCHAR szHelpFile[MAX_PATH];
  3592. TCHAR szHelpLeaf[MAX_PATH];
  3593. TCHAR szTestPath[MAX_PATH];
  3594. // Since we use HTML help, complain if at least IE5 is not found
  3595. BOOL bIE5Found = FALSE;
  3596. HKEY hkey;
  3597. TCHAR szVersion[MAX_PATH];
  3598. DWORD dwType;
  3599. DWORD cbData;
  3600. DWORD dwMajor;
  3601. DWORD dwMinor;
  3602. DWORD dwRevision;
  3603. DWORD dwBuild;
  3604. lstrcpy(szVersion, TEXT(""));
  3605. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  3606. TEXT("Software\\Microsoft\\Internet Explorer"), 0, KEY_READ, &hkey))
  3607. {
  3608. cbData = 100;
  3609. RegQueryValueEx(hkey, TEXT("Version"), 0, &dwType, (LPBYTE)szVersion, &cbData);
  3610. RegCloseKey(hkey);
  3611. if (lstrlen(szVersion) > 0)
  3612. {
  3613. if( _stscanf(szVersion, TEXT("%d.%d.%d.%d"), &dwMajor, &dwMinor, &dwRevision, &dwBuild) == 4 )
  3614. {
  3615. if (dwMajor >= 5)
  3616. bIE5Found = TRUE;
  3617. }
  3618. }
  3619. }
  3620. if (!bIE5Found)
  3621. {
  3622. ReportError(IDS_HELPNEEDSIE5);
  3623. return;
  3624. }
  3625. LoadString(NULL, IDS_HELPFILE, szHelpFile, MAX_PATH);
  3626. if( GetWindowsDirectory(szHelpDir, MAX_PATH) == 0 )
  3627. return;
  3628. LoadString(NULL, IDS_HELPDIRLEAF, szHelpLeaf, MAX_PATH);
  3629. lstrcat(szHelpDir, szHelpLeaf);
  3630. lstrcpy(szTestPath, szHelpDir);
  3631. lstrcat(szTestPath, TEXT("\\"));
  3632. lstrcat(szTestPath, szHelpFile);
  3633. if (GetFileAttributes(szTestPath) == 0xffffffff)
  3634. {
  3635. // File not in windows\help, so try exe's dir:
  3636. GetModuleFileName(NULL, szHelpDir, MAX_PATH);
  3637. TCHAR* pstr = _tcsrchr(szHelpDir, TEXT('\\'));
  3638. if( pstr )
  3639. *pstr = TEXT('\0');
  3640. }
  3641. HINSTANCE hInstResult = ShellExecute( s_hwndMain, NULL, szHelpFile,
  3642. NULL, szHelpDir, SW_SHOWNORMAL ) ;
  3643. if( (INT_PTR)hInstResult < 32 )
  3644. ReportError(IDS_NOHELP);
  3645. }
  3646. /****************************************************************************
  3647. *
  3648. * BTranslateError
  3649. *
  3650. ****************************************************************************/
  3651. BOOL BTranslateError(HRESULT hr, TCHAR* psz, BOOL bEnglish)
  3652. {
  3653. LONG ids;
  3654. switch (hr)
  3655. {
  3656. case E_INVALIDARG: ids = bEnglish ? IDS_INVALIDARG_ENGLISH : IDS_INVALIDARG; break;
  3657. case E_FAIL: ids = bEnglish ? IDS_FAIL_ENGLISH : IDS_FAIL; break;
  3658. case E_UNEXPECTED: ids = bEnglish ? IDS_UNEXPECTED_ENGLISH : IDS_UNEXPECTED; break;
  3659. case E_NOTIMPL: ids = bEnglish ? IDS_NOTIMPL_ENGLISH : IDS_NOTIMPL; break;
  3660. case E_OUTOFMEMORY: ids = bEnglish ? IDS_OUTOFMEMORY_ENGLISH : IDS_OUTOFMEMORY; break;
  3661. case E_NOINTERFACE: ids = bEnglish ? IDS_NOINTERFACE_ENGLISH : IDS_NOINTERFACE; break;
  3662. case REGDB_E_CLASSNOTREG: ids = bEnglish ? IDS_REGDB_E_CLASSNOTREG_ENGLISH : IDS_REGDB_E_CLASSNOTREG; break;
  3663. case DDERR_INVALIDMODE: ids = bEnglish ? IDS_INVALIDMODE_ENGLISH : IDS_INVALIDMODE; break;
  3664. case DDERR_INVALIDPIXELFORMAT: ids = bEnglish ? IDS_INVALIDPIXELFORMAT_ENGLISH : IDS_INVALIDPIXELFORMAT; break;
  3665. case DDERR_CANTCREATEDC: ids = bEnglish ? IDS_CANTCREATEDC_ENGLISH : IDS_CANTCREATEDC; break;
  3666. case DDERR_NOTFOUND: ids = bEnglish ? IDS_NOTFOUND_ENGLISH : IDS_NOTFOUND; break;
  3667. case DDERR_NODIRECTDRAWSUPPORT: ids = bEnglish ? IDS_NODIRECTDRAWSUPPORT_ENGLISH : IDS_NODIRECTDRAWSUPPORT; break;
  3668. case DDERR_NO3D: ids = bEnglish ? IDS_NO3D_ENGLISH : IDS_NO3D; break;
  3669. case D3DERR_INVALID_DEVICE: ids = bEnglish ? IDS_INVALID_DEVICE_ENGLISH : IDS_INVALID_DEVICE; break;
  3670. case D3DERR_INITFAILED: ids = bEnglish ? IDS_INITFAILED_ENGLISH : IDS_INITFAILED; break;
  3671. case D3DERR_MATERIAL_CREATE_FAILED: ids = bEnglish ? IDS_MATERIAL_CREATE_FAILED_ENGLISH : IDS_MATERIAL_CREATE_FAILED; break;
  3672. case D3DERR_LIGHT_SET_FAILED: ids = bEnglish ? IDS_LIGHT_SET_FAILED_ENGLISH : IDS_LIGHT_SET_FAILED; break;
  3673. case DDERR_OUTOFVIDEOMEMORY: ids = bEnglish ? IDS_OUT_OF_VIDEO_MEMORY_ENGLISH : IDS_OUT_OF_VIDEO_MEMORY; break;
  3674. #define D3DERR_NOTAVAILABLE 0x8876086a
  3675. case D3DERR_NOTAVAILABLE: ids = bEnglish ? IDS_D3DERR_NOTAVAILABLE_ENGLISH : IDS_D3DERR_NOTAVAILABLE; break;
  3676. case DSERR_CONTROLUNAVAIL: ids = bEnglish ? IDS_CONTROLUNAVAIL_ENGLISH : IDS_CONTROLUNAVAIL; break;
  3677. case DSERR_BADFORMAT: ids = bEnglish ? IDS_BADFORMAT_ENGLISH : IDS_BADFORMAT; break;
  3678. case DSERR_BUFFERLOST: ids = bEnglish ? IDS_BUFFERLOST_ENGLISH : IDS_BUFFERLOST; break;
  3679. case DSERR_NODRIVER: ids = bEnglish ? IDS_NODRIVER_ENGLISH : IDS_NODRIVER; break;
  3680. case DSERR_ALLOCATED: ids = bEnglish ? IDS_ALLOCATED_ENGLISH : IDS_ALLOCATED; break;
  3681. case DMUS_E_DRIVER_FAILED: ids = bEnglish ? IDS_DRIVER_FAILED_ENGLISH : IDS_DRIVER_FAILED; break;
  3682. case DMUS_E_PORTS_OPEN: ids = bEnglish ? IDS_PORTS_OPEN_ENGLISH : IDS_PORTS_OPEN; break;
  3683. case DMUS_E_DEVICE_IN_USE: ids = bEnglish ? IDS_DEVICE_IN_USE_ENGLISH : IDS_DEVICE_IN_USE; break;
  3684. case DMUS_E_INSUFFICIENTBUFFER: ids = bEnglish ? IDS_INSUFFICIENTBUFFER_ENGLISH : IDS_INSUFFICIENTBUFFER; break;
  3685. case DMUS_E_CHUNKNOTFOUND: ids = bEnglish ? IDS_CHUNKNOTFOUND_ENGLISH : IDS_CHUNKNOTFOUND; break;
  3686. case DMUS_E_BADINSTRUMENT: ids = bEnglish ? IDS_BADINSTRUMENT_ENGLISH : IDS_BADINSTRUMENT; break;
  3687. case DMUS_E_CANNOTREAD: ids = bEnglish ? IDS_CANNOTREAD_ENGLISH : IDS_CANNOTREAD; break;
  3688. case DMUS_E_LOADER_BADPATH: ids = bEnglish ? IDS_LOADER_BADPATH_ENGLISH : IDS_LOADER_BADPATH; break;
  3689. case DMUS_E_LOADER_FAILEDOPEN: ids = bEnglish ? IDS_LOADER_FAILEDOPEN_ENGLISH : IDS_LOADER_FAILEDOPEN; break;
  3690. case DMUS_E_LOADER_FORMATNOTSUPPORTED: ids = bEnglish ? IDS_LOADER_FORMATNOTSUPPORTED_ENGLISH : IDS_LOADER_FORMATNOTSUPPORTED; break;
  3691. case DMUS_E_LOADER_OBJECTNOTFOUND: ids = bEnglish ? IDS_OBJECTNOTFOUND_ENGLISH : IDS_OBJECTNOTFOUND; break;
  3692. case DPERR_ACCESSDENIED: ids = bEnglish ? IDS_DPERR_ACCESSDENIED_ENGLISH : IDS_DPERR_ACCESSDENIED; break;
  3693. case DPERR_CANTADDPLAYER: ids = bEnglish ? IDS_DPERR_CANTADDPLAYER_ENGLISH : IDS_DPERR_CANTADDPLAYER; break;
  3694. case DPERR_CANTCREATESESSION: ids = bEnglish ? IDS_DPERR_CANTCREATESESSION_ENGLISH : IDS_DPERR_CANTCREATESESSION; break;
  3695. case DPERR_EXCEPTION: ids = bEnglish ? IDS_DPERR_EXCEPTION_ENGLISH : IDS_DPERR_EXCEPTION; break;
  3696. case DPERR_INVALIDOBJECT: ids = bEnglish ? IDS_DPERR_INVALIDOBJECT_ENGLISH : IDS_DPERR_INVALIDOBJECT; break;
  3697. case DPERR_NOCONNECTION: ids = bEnglish ? IDS_DPERR_NOCONNECTION_ENGLISH : IDS_DPERR_NOCONNECTION; break;
  3698. case DPERR_TIMEOUT: ids = bEnglish ? IDS_DPERR_TIMEOUT_ENGLISH : IDS_DPERR_TIMEOUT; break;
  3699. case DPERR_BUSY: ids = bEnglish ? IDS_DPERR_BUSY_ENGLISH : IDS_DPERR_BUSY; break;
  3700. case DPERR_CONNECTIONLOST: ids = bEnglish ? IDS_DPERR_CONNECTIONLOST_ENGLISH : IDS_DPERR_CONNECTIONLOST; break;
  3701. case DPERR_NOSERVICEPROVIDER: ids = bEnglish ? IDS_DPERR_NOSERVICEPROVIDER_ENGLISH : IDS_DPERR_NOSERVICEPROVIDER; break;
  3702. case DPERR_UNAVAILABLE: ids = bEnglish ? IDS_DPERR_UNAVAILABLE_ENGLISH : IDS_DPERR_UNAVAILABLE; break;
  3703. default: ids = bEnglish ? IDS_UNKNOWNERROR_ENGLISH : IDS_UNKNOWNERROR; break;
  3704. }
  3705. LoadString(NULL, ids, psz, 200);
  3706. if (ids != IDS_UNKNOWNERROR && ids != IDS_UNKNOWNERROR_ENGLISH)
  3707. return TRUE;
  3708. else
  3709. return FALSE;
  3710. }
  3711. /****************************************************************************
  3712. *
  3713. * RestoreDrivers
  3714. *
  3715. ****************************************************************************/
  3716. VOID RestoreDrivers(VOID)
  3717. {
  3718. TCHAR szDir[MAX_PATH];
  3719. lstrcpy( szDir, TEXT("") );
  3720. if (GetProgramFilesFolder(szDir))
  3721. {
  3722. lstrcat(szDir, TEXT("\\DirectX\\Setup"));
  3723. HINSTANCE hInstResult = ShellExecute( s_hwndMain, NULL, TEXT("DxSetup.exe"),
  3724. NULL, szDir, SW_SHOWNORMAL ) ;
  3725. if( (INT_PTR)hInstResult < 32 )
  3726. ReportError(IDS_NODXSETUP);
  3727. }
  3728. }
  3729. /****************************************************************************
  3730. *
  3731. * BCanRestoreDrivers - Returns whether backed-up drivers can be restored.
  3732. * This function checks for the presence of dxsetup.exe where it should
  3733. * be, and the existence of files in either <system>\dxbackup\display or
  3734. * <system>\dxbackup\media.
  3735. *
  3736. ****************************************************************************/
  3737. BOOL BCanRestoreDrivers(VOID)
  3738. {
  3739. TCHAR szPath[MAX_PATH];
  3740. lstrcpy( szPath, TEXT("") );
  3741. if (!GetProgramFilesFolder(szPath))
  3742. return FALSE;
  3743. lstrcat(szPath, TEXT("\\DirectX\\Setup\\DxSetup.exe"));
  3744. if (GetFileAttributes(szPath) == 0xffffffff)
  3745. return FALSE;
  3746. if (!GetSystemDirectory(szPath, MAX_PATH))
  3747. return FALSE;
  3748. lstrcat(szPath, TEXT("\\dxbackup\\display"));
  3749. if (GetFileAttributes(szPath) != 0xffffffff)
  3750. return TRUE;
  3751. if (!GetSystemDirectory(szPath, MAX_PATH))
  3752. return FALSE;
  3753. lstrcat(szPath, TEXT("\\dxbackup\\media"));
  3754. if (GetFileAttributes(szPath) != 0xffffffff)
  3755. return TRUE;
  3756. return FALSE;
  3757. }
  3758. /****************************************************************************
  3759. *
  3760. * HandleSndSliderChange
  3761. *
  3762. ****************************************************************************/
  3763. VOID HandleSndSliderChange(INT nScrollCode, INT nPos)
  3764. {
  3765. TCHAR sz[MAX_PATH];
  3766. if (nScrollCode != SB_THUMBTRACK && nScrollCode != SB_THUMBPOSITION)
  3767. nPos = (INT)SendMessage(GetDlgItem(s_hwndCurPage, IDC_SNDACCELSLIDER), TBM_GETPOS, 0, 0);
  3768. if (nScrollCode == SB_THUMBTRACK ||
  3769. nScrollCode == SB_LEFT ||
  3770. nScrollCode == SB_RIGHT ||
  3771. nScrollCode == SB_LINELEFT ||
  3772. nScrollCode == SB_LINERIGHT ||
  3773. nScrollCode == SB_PAGELEFT ||
  3774. nScrollCode == SB_PAGERIGHT)
  3775. {
  3776. switch (nPos)
  3777. {
  3778. case 0:
  3779. LoadString(NULL, IDS_NOSNDACCELERATION, sz, MAX_PATH);
  3780. break;
  3781. case 1:
  3782. LoadString(NULL, IDS_BASICSNDACCELERATION, sz, MAX_PATH);
  3783. break;
  3784. case 2:
  3785. LoadString(NULL, IDS_STANDARDSNDACCELERATION, sz, MAX_PATH);
  3786. break;
  3787. case 3:
  3788. LoadString(NULL, IDS_FULLSNDACCELERATION, sz, MAX_PATH);
  3789. break;
  3790. default:
  3791. lstrcpy(sz, TEXT(""));
  3792. break;
  3793. }
  3794. SetWindowText(GetDlgItem(s_hwndCurPage, IDC_SNDACCELDESC), sz);
  3795. }
  3796. if (nScrollCode != SB_THUMBTRACK && nScrollCode != SB_ENDSCROLL &&
  3797. s_pSoundInfoFirst != NULL )
  3798. {
  3799. HRESULT hr;
  3800. SoundInfo* pSoundInfo = s_pSoundInfoFirst;
  3801. LONG iSound = s_lwCurPage - s_iPageSoundFirst;
  3802. while (iSound > 0)
  3803. {
  3804. pSoundInfo = pSoundInfo->m_pSoundInfoNext;
  3805. iSound--;
  3806. }
  3807. if (nPos != pSoundInfo->m_lwAccelerationLevel)
  3808. {
  3809. if (FAILED(hr = ChangeAccelerationLevel(pSoundInfo, nPos)))
  3810. {
  3811. // TODO: report error
  3812. }
  3813. DestroySoundInfo(s_pSoundInfoFirst);
  3814. pSoundInfo = NULL;
  3815. s_pSoundInfoFirst = NULL;
  3816. // ******* GetBasicSoundInfo (DS:1) ********
  3817. s_bUseDSound = QueryCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, IDS_DS, 1 );
  3818. if( s_bUseDSound )
  3819. {
  3820. EnterCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 1 );
  3821. if (FAILED(hr = GetBasicSoundInfo(&s_pSoundInfoFirst)))
  3822. ReportError(IDS_NOBASICSOUNDINFO, hr);
  3823. LeaveCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 1 );
  3824. }
  3825. // ******* GetExtraSoundInfo (DS:2) ********
  3826. if( s_bUseDSound )
  3827. {
  3828. s_bUseDSound = QueryCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, IDS_DS, 2 );
  3829. if( s_bUseDSound )
  3830. {
  3831. EnterCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 2 );
  3832. if (FAILED(hr = GetExtraSoundInfo(s_pSoundInfoFirst)))
  3833. ReportError(IDS_NOEXTRASOUNDINFO, hr);
  3834. LeaveCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 2 );
  3835. }
  3836. }
  3837. // ******* GetDSSoundInfo (DS:3) ********
  3838. if( s_bUseDSound )
  3839. {
  3840. s_bUseDSound = QueryCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, IDS_DS, 3 );
  3841. if( s_bUseDSound )
  3842. {
  3843. EnterCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 3 );
  3844. if (FAILED(hr = GetDSSoundInfo(s_pSoundInfoFirst)))
  3845. ReportError(IDS_NOEXTRASOUNDINFO, hr);
  3846. LeaveCrashProtection( DXD_IN_DS_KEY, DXD_IN_DS_VALUE, 3 );
  3847. }
  3848. }
  3849. SetupSoundPage( s_lwCurPage - s_iPageSoundFirst );
  3850. }
  3851. }
  3852. }
  3853. /****************************************************************************
  3854. *
  3855. * TroubleShoot
  3856. *
  3857. ****************************************************************************/
  3858. VOID TroubleShoot( BOOL bTroubleShootSound )
  3859. {
  3860. TCHAR szHelpDir[MAX_PATH];
  3861. TCHAR szHelpLeaf[MAX_PATH];
  3862. TCHAR szHelpExe[MAX_PATH];
  3863. TCHAR szTroubleshooter[MAX_PATH];
  3864. TCHAR szSubInfo[MAX_PATH];
  3865. if( GetWindowsDirectory(szHelpDir, MAX_PATH) == 0 )
  3866. return;
  3867. LoadString(NULL, IDS_HELPDIRLEAF, szHelpLeaf, MAX_PATH);
  3868. LoadString(NULL, IDS_HELPEXE, szHelpExe, MAX_PATH);
  3869. lstrcat(szHelpDir, szHelpLeaf);
  3870. if( bTroubleShootSound )
  3871. {
  3872. if( BIsWin98() || BIsWin95() )
  3873. {
  3874. TCHAR szHelpPath[MAX_PATH];
  3875. LoadString(NULL, IDS_TROUBLESHOOTER_WIN98SE, szTroubleshooter, MAX_PATH);
  3876. lstrcpy(szHelpPath, szHelpDir);
  3877. lstrcat(szHelpPath, TEXT("\\"));
  3878. lstrcat(szHelpPath, szTroubleshooter);
  3879. if (GetFileAttributes(szHelpPath) == 0xffffffff)
  3880. {
  3881. LoadString(NULL, IDS_SOUNDTROUBLESHOOTER_WIN98, szTroubleshooter, MAX_PATH);
  3882. lstrcpy( szSubInfo, TEXT("") );
  3883. }
  3884. else
  3885. {
  3886. LoadString(NULL, IDS_TROUBLESHOOTER_WIN98SE, szTroubleshooter, MAX_PATH);
  3887. LoadString(NULL, IDS_TSSOUNDSUBINFO_WIN98SE, szSubInfo, MAX_PATH);
  3888. }
  3889. }
  3890. else if( BIsWinME() )
  3891. {
  3892. LoadString(NULL, IDS_TROUBLESHOOTER_WINME_HCP, szHelpExe, MAX_PATH);
  3893. LoadString(NULL, IDS_TSSOUNDSUBINFO_WINME_HCP, szSubInfo, MAX_PATH);
  3894. lstrcat(szHelpExe, szSubInfo);
  3895. lstrcpy(szTroubleshooter, TEXT("") );
  3896. lstrcpy(szSubInfo, TEXT("") );
  3897. }
  3898. else if( BIsWin2k() )
  3899. {
  3900. LoadString(NULL, IDS_TROUBLESHOOTER_WIN2K, szTroubleshooter, MAX_PATH);
  3901. LoadString(NULL, IDS_TSSOUNDSUBINFO_WIN2K, szSubInfo, MAX_PATH);
  3902. }
  3903. else // if( BIsWhistler() )
  3904. {
  3905. lstrcpy( szHelpExe, TEXT("hcp://help/tshoot/tssound.htm") );
  3906. lstrcpy( szTroubleshooter, TEXT("") );
  3907. lstrcpy( szSubInfo, TEXT("") );
  3908. }
  3909. }
  3910. else
  3911. {
  3912. if( BIsWin98() || BIsWin95() )
  3913. {
  3914. TCHAR szHelpPath[MAX_PATH];
  3915. LoadString(NULL, IDS_TROUBLESHOOTER_WIN98SE, szTroubleshooter, MAX_PATH);
  3916. lstrcpy(szHelpPath, szHelpDir);
  3917. lstrcat(szHelpPath, TEXT("\\"));
  3918. lstrcat(szHelpPath, szTroubleshooter);
  3919. if (GetFileAttributes(szHelpPath) == 0xffffffff)
  3920. {
  3921. LoadString(NULL, IDS_TROUBLESHOOTER_WIN98, szTroubleshooter, MAX_PATH);
  3922. lstrcpy( szSubInfo, TEXT("") );
  3923. }
  3924. else
  3925. {
  3926. LoadString(NULL, IDS_TROUBLESHOOTER_WIN98SE, szTroubleshooter, MAX_PATH);
  3927. LoadString(NULL, IDS_TSSUBINFO_WIN98SE, szSubInfo, MAX_PATH);
  3928. }
  3929. }
  3930. else if( BIsWinME() )
  3931. {
  3932. LoadString(NULL, IDS_TROUBLESHOOTER_WINME_HCP, szHelpExe, MAX_PATH);
  3933. LoadString(NULL, IDS_TSSUBINFO_WINME_HCP, szSubInfo, MAX_PATH);
  3934. lstrcat(szHelpExe, szSubInfo);
  3935. lstrcpy(szTroubleshooter, TEXT("") );
  3936. lstrcpy(szSubInfo, TEXT("") );
  3937. }
  3938. else if( BIsWin2k() )
  3939. {
  3940. LoadString(NULL, IDS_TROUBLESHOOTER_WIN2K, szTroubleshooter, MAX_PATH);
  3941. LoadString(NULL, IDS_TSSUBINFO_WIN2K, szSubInfo, MAX_PATH);
  3942. }
  3943. else // if( BIsWhistler() )
  3944. {
  3945. lstrcpy( szHelpExe, TEXT("hcp://help/tshoot/tsgame.htm") );
  3946. lstrcpy( szTroubleshooter, TEXT("") );
  3947. lstrcpy( szSubInfo, TEXT("") );
  3948. }
  3949. }
  3950. lstrcat(szTroubleshooter, szSubInfo);
  3951. HINSTANCE hInstResult = ShellExecute( s_hwndMain, NULL, szHelpExe,
  3952. szTroubleshooter,
  3953. szHelpDir, SW_SHOWNORMAL ) ;
  3954. if( (INT_PTR)hInstResult < 32 )
  3955. ReportError(IDS_NOTROUBLESHOOTER);
  3956. }
  3957. /****************************************************************************
  3958. *
  3959. * QueryCrashProtection
  3960. *
  3961. ****************************************************************************/
  3962. BOOL QueryCrashProtection( TCHAR* strKey, TCHAR* strValue,
  3963. int nSkipComponent, DWORD dwCurrentStep )
  3964. {
  3965. HKEY hkey = NULL;
  3966. BOOL bAllowCall = TRUE;
  3967. // Open the key
  3968. if( ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, strKey, 0, KEY_ALL_ACCESS, &hkey) )
  3969. {
  3970. DWORD dwType = 0;
  3971. DWORD dwCrashedOnStep = 0;
  3972. DWORD cbData = sizeof(dwCrashedOnStep);
  3973. // Query the key for the value of where the last crash occurred
  3974. if( ERROR_SUCCESS == RegQueryValueEx( hkey, strValue, 0, &dwType,
  3975. (BYTE*)&dwCrashedOnStep, &cbData) )
  3976. {
  3977. // If we are at or beyond the crash step, then ask the user
  3978. // to continue or not
  3979. if( dwCurrentStep >= dwCrashedOnStep )
  3980. {
  3981. if( !s_bGUI )
  3982. {
  3983. // If there's no gui, don't ask just don't use it
  3984. bAllowCall = FALSE;
  3985. }
  3986. else
  3987. {
  3988. // If the UI is alive then have it ask the user,
  3989. // otherwise do it ourselves
  3990. if( s_hwndMain && s_hUIThread )
  3991. {
  3992. // Mark down which component we're skipping in s_nSkipComponent,
  3993. // and then post a WM_QUERYSKIP message to the UI thread
  3994. // it will process this message, ask the user, and signal the
  3995. // s_hQuerySkipEvent event.
  3996. s_nSkipComponent = nSkipComponent;
  3997. PostMessage( s_hwndMain, WM_QUERYSKIP, 0, 0 );
  3998. HANDLE aWait[2];
  3999. DWORD dwResult;
  4000. aWait[0] = s_hQuerySkipEvent;
  4001. aWait[1] = s_hUIThread;
  4002. // Its possible that the UI thread exited before it processed the
  4003. // WM_QUERYSKIP message, so wait for either the event and thread exiting
  4004. dwResult = WaitForMultipleObjects( 2, aWait, FALSE, INFINITE );
  4005. // If the event was signaled, then get the result from s_bQuerySkipAllow,
  4006. // otherwise skip this call (the main code will exit if it sees the UI thread gone)
  4007. if( dwResult == WAIT_OBJECT_0 )
  4008. bAllowCall = s_bQuerySkipAllow;
  4009. else
  4010. bAllowCall = FALSE;
  4011. }
  4012. else
  4013. {
  4014. // If there's is no gui, ask if to use it now
  4015. TCHAR szTitle[MAX_PATH];
  4016. TCHAR szMessage[MAX_PATH];
  4017. TCHAR szFmt[MAX_PATH];
  4018. TCHAR szMessageComponent[MAX_PATH];
  4019. LoadString(0, IDS_APPFULLNAME, szTitle, MAX_PATH);
  4020. LoadString(0, IDS_SKIP, szFmt, MAX_PATH);
  4021. LoadString(0, nSkipComponent, szMessageComponent, MAX_PATH);
  4022. wsprintf( szMessage, szFmt, szMessageComponent, szMessageComponent );
  4023. if( IDYES == MessageBox( s_hwndMain, szMessage, szTitle, MB_YESNO) )
  4024. bAllowCall = FALSE;
  4025. }
  4026. }
  4027. }
  4028. }
  4029. RegCloseKey(hkey);
  4030. }
  4031. return bAllowCall;
  4032. }
  4033. /****************************************************************************
  4034. *
  4035. * EnterCrashProtection
  4036. *
  4037. ****************************************************************************/
  4038. VOID EnterCrashProtection( TCHAR* strKey, TCHAR* strValue, DWORD dwCurrentStep )
  4039. {
  4040. HKEY hkey = NULL;
  4041. BOOL bSetValue = FALSE;
  4042. DWORD dwDisposition;
  4043. // Write reg key indicating we are inside the crash protection
  4044. if( ERROR_SUCCESS == RegCreateKeyEx( HKEY_LOCAL_MACHINE, strKey, 0,
  4045. NULL, REG_OPTION_NON_VOLATILE,
  4046. KEY_ALL_ACCESS, NULL, &hkey, &dwDisposition) )
  4047. {
  4048. DWORD dwType = 0;
  4049. DWORD dwCrashedOnStep = 0;
  4050. DWORD cbData = sizeof(dwCrashedOnStep);
  4051. // Query the key for the value of where the last crash occurred
  4052. if( ERROR_SUCCESS == RegQueryValueEx( hkey, strValue, 0, &dwType,
  4053. (BYTE*)&dwCrashedOnStep, &cbData) )
  4054. {
  4055. // If we are beyond whats currently in the reg, then update the value
  4056. if( dwCurrentStep > dwCrashedOnStep )
  4057. bSetValue = TRUE;
  4058. }
  4059. else
  4060. {
  4061. // If the value doesn't exist current, then create it
  4062. bSetValue = TRUE;
  4063. }
  4064. if( bSetValue )
  4065. {
  4066. RegSetValueEx( hkey, strValue, 0, REG_DWORD,
  4067. (BYTE*)&dwCurrentStep, sizeof(dwCurrentStep));
  4068. }
  4069. RegCloseKey(hkey);
  4070. }
  4071. }
  4072. /****************************************************************************
  4073. *
  4074. * LeaveCrashProtection
  4075. *
  4076. ****************************************************************************/
  4077. VOID LeaveCrashProtection( TCHAR* strKey, TCHAR* strValue, DWORD dwCurrentStep )
  4078. {
  4079. HKEY hkey = NULL;
  4080. // Remove reg key since we're done with the crash protection
  4081. if (ERROR_SUCCESS == RegOpenKeyEx( HKEY_LOCAL_MACHINE, strKey, 0,
  4082. KEY_ALL_ACCESS, &hkey))
  4083. {
  4084. DWORD dwType = 0;
  4085. DWORD dwCrashedOnStep = 0;
  4086. DWORD cbData = sizeof(dwCrashedOnStep);
  4087. // Query the key for the value of where the last crash occurred
  4088. if( ERROR_SUCCESS == RegQueryValueEx( hkey, strValue, 0, &dwType,
  4089. (BYTE*)&dwCrashedOnStep, &cbData) )
  4090. {
  4091. // If we are at or beyond that crash step, then delete the key
  4092. if( dwCurrentStep >= dwCrashedOnStep )
  4093. {
  4094. RegDeleteValue(hkey, strValue);
  4095. }
  4096. }
  4097. RegCloseKey(hkey);
  4098. }
  4099. }
  4100. /****************************************************************************
  4101. *
  4102. * TestD3D
  4103. *
  4104. ****************************************************************************/
  4105. VOID TestD3D(HWND hwndMain, DisplayInfo* pDisplayInfo)
  4106. {
  4107. TCHAR sz[MAX_PATH];
  4108. TCHAR szTitle[MAX_PATH];
  4109. LoadString(NULL, IDS_STARTD3DTEST, sz, MAX_PATH);
  4110. LoadString(NULL, IDS_APPFULLNAME, szTitle, MAX_PATH);
  4111. if (IDNO == MessageBox(hwndMain, sz, szTitle, MB_YESNO))
  4112. return;
  4113. // Erase old D3D7 test results
  4114. ZeroMemory(&pDisplayInfo->m_testResultD3D7, sizeof(TestResult));
  4115. pDisplayInfo->m_testResultD3D7.m_bStarted = TRUE;
  4116. // Erase old D3D8 test results
  4117. ZeroMemory(&pDisplayInfo->m_testResultD3D8, sizeof(TestResult));
  4118. pDisplayInfo->m_testResultD3D8.m_bStarted = TRUE;
  4119. if( FALSE == BIsIA64() )
  4120. {
  4121. // First test (D3D7)
  4122. LoadString(NULL, IDS_D3DTEST1, sz, MAX_PATH);
  4123. if (IDCANCEL == MessageBox(hwndMain, sz, szTitle, MB_OKCANCEL))
  4124. {
  4125. pDisplayInfo->m_testResultD3D7.m_bCancelled = TRUE;
  4126. goto LEnd;
  4127. }
  4128. // Run D3D7 test
  4129. TestD3Dv7( TRUE, hwndMain, pDisplayInfo );
  4130. if( pDisplayInfo->m_testResultD3D7.m_bCancelled ||
  4131. pDisplayInfo->m_testResultD3D7.m_iStepThatFailed != 0 )
  4132. goto LEnd;
  4133. }
  4134. // Second test (D3D8)
  4135. LoadString(NULL, IDS_D3DTEST2, sz, MAX_PATH);
  4136. if (IDCANCEL == MessageBox(hwndMain, sz, szTitle, MB_OKCANCEL))
  4137. {
  4138. pDisplayInfo->m_testResultD3D8.m_bCancelled = TRUE;
  4139. goto LEnd;
  4140. }
  4141. // Run D3D8 test
  4142. TestD3Dv8( TRUE, hwndMain, pDisplayInfo );
  4143. if( pDisplayInfo->m_testResultD3D8.m_bCancelled ||
  4144. pDisplayInfo->m_testResultD3D8.m_iStepThatFailed != 0 )
  4145. goto LEnd;
  4146. LEnd:
  4147. // Default to displaying results of D3D8 tests
  4148. pDisplayInfo->m_dwTestToDisplayD3D = 8;
  4149. if (pDisplayInfo->m_testResultD3D7.m_bCancelled || pDisplayInfo->m_testResultD3D8.m_bCancelled)
  4150. {
  4151. LoadString(NULL, IDS_TESTSCANCELLED, sz, MAX_PATH);
  4152. lstrcpy(pDisplayInfo->m_testResultD3D7.m_szDescription, sz);
  4153. lstrcpy(pDisplayInfo->m_testResultD3D8.m_szDescription, sz);
  4154. LoadString(NULL, IDS_TESTSCANCELLED_ENGLISH, sz, MAX_PATH);
  4155. lstrcpy(pDisplayInfo->m_testResultD3D7.m_szDescriptionEnglish, sz);
  4156. lstrcpy(pDisplayInfo->m_testResultD3D8.m_szDescriptionEnglish, sz);
  4157. }
  4158. else
  4159. {
  4160. if( pDisplayInfo->m_testResultD3D7.m_iStepThatFailed == 0 )
  4161. {
  4162. LoadString(NULL, IDS_TESTSSUCCESSFUL_ENGLISH, sz, MAX_PATH);
  4163. lstrcpy(pDisplayInfo->m_testResultD3D7.m_szDescriptionEnglish, sz);
  4164. LoadString(NULL, IDS_TESTSSUCCESSFUL, sz, MAX_PATH);
  4165. lstrcpy(pDisplayInfo->m_testResultD3D7.m_szDescription, sz);
  4166. }
  4167. if( pDisplayInfo->m_testResultD3D8.m_iStepThatFailed == 0 )
  4168. {
  4169. LoadString(NULL, IDS_TESTSSUCCESSFUL, sz, MAX_PATH);
  4170. lstrcpy(pDisplayInfo->m_testResultD3D8.m_szDescription, sz);
  4171. LoadString(NULL, IDS_TESTSSUCCESSFUL_ENGLISH, sz, MAX_PATH);
  4172. lstrcpy(pDisplayInfo->m_testResultD3D8.m_szDescriptionEnglish, sz);
  4173. }
  4174. if( pDisplayInfo->m_testResultD3D7.m_iStepThatFailed != 0 ||
  4175. pDisplayInfo->m_testResultD3D8.m_iStepThatFailed != 0 )
  4176. {
  4177. TCHAR szDesc[MAX_PATH];
  4178. TCHAR szError[MAX_PATH];
  4179. TestResult* pFailedTestResult = NULL;
  4180. if( pDisplayInfo->m_testResultD3D7.m_iStepThatFailed != 0 )
  4181. {
  4182. pFailedTestResult = &pDisplayInfo->m_testResultD3D7;
  4183. pDisplayInfo->m_dwTestToDisplayD3D = 7;
  4184. }
  4185. else
  4186. {
  4187. pFailedTestResult = &pDisplayInfo->m_testResultD3D8;
  4188. pDisplayInfo->m_dwTestToDisplayD3D = 8;
  4189. }
  4190. if (0 == LoadString(NULL, IDS_FIRSTD3DTESTERROR + pFailedTestResult->m_iStepThatFailed - 1,
  4191. szDesc, MAX_PATH))
  4192. {
  4193. LoadString(NULL, IDS_UNKNOWNERROR, sz, MAX_PATH);
  4194. lstrcpy(szDesc, sz);
  4195. }
  4196. LoadString(NULL, IDS_FAILUREFMT, sz, MAX_PATH);
  4197. BTranslateError(pFailedTestResult->m_hr, szError);
  4198. wsprintf(pFailedTestResult->m_szDescription, sz,
  4199. pFailedTestResult->m_iStepThatFailed,
  4200. szDesc, pFailedTestResult->m_hr, szError);
  4201. // Nonlocalized version:
  4202. if (0 == LoadString(NULL, IDS_FIRSTD3DTESTERROR_ENGLISH + pFailedTestResult->m_iStepThatFailed - 1,
  4203. szDesc, MAX_PATH))
  4204. {
  4205. LoadString(NULL, IDS_UNKNOWNERROR_ENGLISH, sz, MAX_PATH);
  4206. lstrcpy(szDesc, sz);
  4207. }
  4208. LoadString(NULL, IDS_FAILUREFMT_ENGLISH, sz, MAX_PATH);
  4209. BTranslateError(pFailedTestResult->m_hr, szError, TRUE);
  4210. wsprintf(pFailedTestResult->m_szDescriptionEnglish, sz,
  4211. pFailedTestResult->m_iStepThatFailed,
  4212. szDesc, pFailedTestResult->m_hr, szError);
  4213. }
  4214. }
  4215. }
  4216. /****************************************************************************
  4217. *
  4218. * GetTxtPath
  4219. *
  4220. ****************************************************************************/
  4221. BOOL GetTxtPath( TCHAR* strTxtPath )
  4222. {
  4223. HKEY hkey = NULL;
  4224. BOOL bFound = FALSE;
  4225. DWORD ulType;
  4226. DWORD cbData;
  4227. // Get default user info from registry
  4228. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\DirectX Diagnostic Tool"),
  4229. 0, KEY_READ, &hkey))
  4230. {
  4231. cbData = MAX_PATH;
  4232. if( ERROR_SUCCESS == RegQueryValueEx(hkey, TEXT("TxtPath"), 0, &ulType, (LPBYTE)strTxtPath, &cbData ) )
  4233. bFound = TRUE;
  4234. RegCloseKey(hkey);
  4235. }
  4236. if( !bFound )
  4237. {
  4238. HKEY hkeyFolder;
  4239. // Same as SHGetSpecialFolderPath( hwnd, szFilename, CSIDL_DESKTOPDIRECTORY, FALSE );
  4240. if (ERROR_SUCCESS == RegOpenKeyEx( HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"),
  4241. 0, KEY_READ, &hkeyFolder) )
  4242. {
  4243. cbData = MAX_PATH;
  4244. if (ERROR_SUCCESS == RegQueryValueEx( hkeyFolder, TEXT("Desktop"), 0, &ulType, (LPBYTE)strTxtPath, &cbData ) )
  4245. bFound = TRUE;
  4246. RegCloseKey( hkeyFolder );
  4247. }
  4248. }
  4249. return bFound;
  4250. }
  4251. /****************************************************************************
  4252. *
  4253. * SetTxtPath
  4254. *
  4255. ****************************************************************************/
  4256. VOID SetTxtPath( TCHAR* strTxtPath )
  4257. {
  4258. HKEY hkey = NULL;
  4259. // Try to save user info into registry
  4260. if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\DirectX Diagnostic Tool"),
  4261. 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL))
  4262. {
  4263. RegSetValueEx(hkey, TEXT("TxtPath"), 0, REG_SZ, (BYTE*)strTxtPath, sizeof(TCHAR)*(lstrlen(strTxtPath) + 1));
  4264. RegCloseKey(hkey);
  4265. }
  4266. }