2 * PROJECT: ReactX Diagnosis Application
3 * LICENSE: LGPL - See COPYING in the top level directory
4 * FILE: base/applications/dxdiag/dxdiag.c
5 * PURPOSE: ReactX diagnosis network page
6 * COPYRIGHT: Copyright 2008 Johannes Anderwald
18 typedef struct _LANGANDCODEPAGE_
22 } LANGANDCODEPAGE
, *LPLANGANDCODEPAGE
;
24 static DIRECTPLAY_GUID DirectPlay8SP
[] =
27 L
"{6D4A3650-628D-11D2-AE0F-006097B01411}",
28 IDS_DIRECTPLAY8_MODEMSP
31 L
"{743B5D60-628D-11D2-AE0F-006097B01411}",
32 IDS_DIRECTPLAY8_SERIALSP
35 L
"{53934290-628D-11D2-AE0F-006097B01411}",
39 L
"{EBFE7BA0-628D-11D2-AE0F-006097B01411}",
44 static DIRECTPLAY_GUID DirectPlaySP
[] =
47 L
"{36E95EE0-8577-11cf-960C-0080C7534E82}",
48 IDS_DIRECTPLAY_TCPCONN
51 L
"685BC400-9D2C-11cf-A9CD-00AA006886E3",
52 IDS_DIRECTPLAY_IPXCONN
55 L
"{44EAA760-CB68-11cf-9C4E-00A0C905425E}",
56 IDS_DIRECTPLAY_MODEMCONN
59 L
"{0F1D6860-88D9-11cf-9C4E-00A0C905425E}",
60 IDS_DIRECTPLAY_SERIALCONN
66 InitListViewColumns(HWND hDlgCtrl
)
72 ZeroMemory(&lvcolumn
, sizeof(LVCOLUMNW
));
73 lvcolumn
.pszText
= szText
;
74 lvcolumn
.mask
= LVCF_FMT
| LVCF_TEXT
| LVCF_SUBITEM
| LVCF_WIDTH
;
75 lvcolumn
.fmt
= LVCFMT_LEFT
;
78 for(Index
= 0; Index
< 4; Index
++)
81 LoadStringW(hInst
, IDS_DIRECTPLAY_COL_NAME1
+ Index
, szText
, sizeof(szText
) / sizeof(WCHAR
));
82 szText
[(sizeof(szText
) / sizeof(WCHAR
))-1] = L
'\0';
85 if (SendMessageW(hDlgCtrl
, LVM_INSERTCOLUMNW
, Index
, (LPARAM
)&lvcolumn
) == -1)
91 FindProviderIndex(LPCWSTR szGuid
, DIRECTPLAY_GUID
* PreDefProviders
)
94 for(Index
= 0; Index
< 4; Index
++)
96 if (!wcsncmp(PreDefProviders
[Index
].Guid
, szGuid
, 40))
103 GetFileVersion(LPCWSTR szAppName
, WCHAR
* szVer
, DWORD szVerSize
)
110 LPLANGANDCODEPAGE lplangcode
;
113 BOOL bResult
= FALSE
;
116 static const WCHAR wFormat
[] = L
"\\StringFileInfo\\%04x%04x\\FileVersion";
117 static const WCHAR wTranslation
[] = L
"VarFileInfo\\Translation";
119 /* query version info size */
120 VerSize
= GetFileVersionInfoSizeW(szAppName
, &DummyHandle
);
125 /* allocate buffer */
126 pBuf
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, VerSize
);
131 /* query version info */
132 if(!GetFileVersionInfoW(szAppName
, 0, VerSize
, pBuf
))
134 HeapFree(GetProcessHeap(), 0, pBuf
);
138 /* query lang code */
139 if(VerQueryValueW(pBuf
, wTranslation
, (LPVOID
*)&lplangcode
, &VerSize
))
141 /* FIXME find language from current locale / if not available,
143 * for now default to first available language
145 lang
= lplangcode
->lang
;
146 code
= lplangcode
->code
;
149 wsprintfW(szBuffer
, wFormat
, lang
, code
);
150 /* query manufacturer */
152 bVer
= VerQueryValueW(pBuf
, szBuffer
, (LPVOID
*)&pResult
, &VerSize
);
154 if (VerSize
< szVerSize
&& bVer
&& pResult
)
156 wcscpy(szVer
, pResult
);
157 pResult
= wcschr(szVer
, L
' ');
160 /* cut off build info */
161 VerSize
= (pResult
- szVer
);
163 if (GetLocaleInfoW(MAKELCID(lang
, SORT_DEFAULT
), LOCALE_SLANGUAGE
, &szVer
[VerSize
], szVerSize
-VerSize
))
165 szVer
[VerSize
-1] = L
' ';
166 szVer
[szVerSize
-1] = L
'\0';
171 HeapFree(GetProcessHeap(), 0, pBuf
);
177 EnumerateServiceProviders(HKEY hKey
, HWND hDlgCtrl
, DIRECTPLAY_GUID
* PreDefProviders
)
184 WCHAR szResult
[MAX_PATH
+20] = {0};
185 DWORD RegProviders
= 0;
193 ItemCount
= ListView_GetItemCount(hDlgCtrl
);
194 ZeroMemory(&Item
, sizeof(LVITEMW
));
195 Item
.mask
= LVIF_TEXT
;
196 Item
.pszText
= szResult
;
197 Item
.iItem
= ItemCount
;
198 /* insert all predefined items first */
199 for(dwIndex
= 0; dwIndex
< 4; dwIndex
++)
201 Item
.iItem
= ItemCount
+ dwIndex
;
204 LoadStringW(hInst
, PreDefProviders
[dwIndex
].ResourceID
, szResult
, sizeof(szResult
)/sizeof(WCHAR
));
205 szResult
[(sizeof(szResult
)/sizeof(WCHAR
))-1] = L
'\0';
206 lResult
= SendMessageW(hDlgCtrl
, LVM_INSERTITEM
, 0, (LPARAM
)&Item
);
208 LoadStringW(hInst
, IDS_REG_FAIL
, szResult
, sizeof(szResult
)/sizeof(WCHAR
));
209 szResult
[(sizeof(szResult
)/sizeof(WCHAR
))-1] = L
'\0';
210 Item
.iItem
= lResult
;
212 lResult
= SendMessageW(hDlgCtrl
, LVM_SETITEM
, 0, (LPARAM
)&Item
);
218 dwName
= sizeof(szName
) / sizeof(WCHAR
);
219 result
= RegEnumKeyEx(hKey
, dwIndex
, szName
, &dwName
, NULL
, NULL
, NULL
, NULL
);
220 if (result
== ERROR_SUCCESS
)
222 szName
[(sizeof(szName
)/sizeof(WCHAR
))-1] = L
'\0';
224 ProviderIndex
= UINT_MAX
;
225 if (GetRegValue(hKey
, szName
, L
"GUID", REG_SZ
, szGUID
, sizeof(szGUID
)))
226 ProviderIndex
= FindProviderIndex(szGUID
, PreDefProviders
);
228 if (ProviderIndex
== UINT_MAX
)
230 /* a custom service provider was found */
231 lResult
= ListView_GetItemCount(hDlgCtrl
);
232 Item
.iItem
= lResult
;
235 * on Windows Vista we need to use RegLoadMUIString which is not available for older systems
237 if (!GetRegValue(hKey
, szName
, L
"Friendly Name", REG_SZ
, szResult
, sizeof(szResult
)))
238 if (!GetRegValue(hKey
, szName
, L
"DescriptionW", REG_SZ
, szResult
, sizeof(szResult
)))
241 /* insert the new provider */
243 lResult
= SendMessageW(hDlgCtrl
, LVM_INSERTITEM
, 0, (LPARAM
)&Item
);
245 ProviderIndex
= lResult
- ItemCount
;
249 /* check if the 'Path' key is available */
250 if (!GetRegValue(hKey
, szName
, L
"Path", REG_SZ
, szResult
, sizeof(szResult
)))
252 /* retrieve the path by lookup the CLSID */
253 wcscpy(szTemp
, L
"CLSID\\");
254 wcscpy(&szTemp
[6], szGUID
);
255 wcscpy(&szTemp
[44], L
"\\InProcServer32");
256 if (!GetRegValue(HKEY_CLASSES_ROOT
, szTemp
, NULL
, REG_SZ
, szResult
, sizeof(szResult
)))
259 ProviderIndex
= UINT_MAX
;
264 /* insert path name */
266 Item
.iItem
= ProviderIndex
+ ItemCount
;
267 SendMessageW(hDlgCtrl
, LVM_SETITEM
, 0, (LPARAM
)&Item
);
268 /* retrieve file version */
269 if (!GetFileVersion(szResult
, szTemp
, sizeof(szTemp
)/sizeof(WCHAR
)))
272 LoadStringW(hInst
, IDS_VERSION_UNKNOWN
, szTemp
, sizeof(szTemp
)/sizeof(WCHAR
));
273 szTemp
[(sizeof(szTemp
)/sizeof(WCHAR
))-1] = L
'\0';
276 Item
.pszText
= szTemp
;
277 SendMessageW(hDlgCtrl
, LVM_SETITEM
, 0, (LPARAM
)&Item
);
278 Item
.pszText
= szResult
;
281 if (ProviderIndex
!= UINT_MAX
)
283 RegProviders
|= (1 << ProviderIndex
);
285 LoadStringW(hInst
, IDS_REG_SUCCESS
, szResult
, sizeof(szResult
));
288 Item
.iItem
= ProviderIndex
+ ItemCount
;
289 szResult
[(sizeof(szResult
)/sizeof(WCHAR
))-1] = L
'\0';
290 SendMessageW(hDlgCtrl
, LVM_SETITEM
, 0, (LPARAM
)&Item
);
294 }while(result
!= ERROR_NO_MORE_ITEMS
);
296 /* check if all providers have been registered */
297 // if (RegProviders == 15)
306 InitializeDirectPlayDialog(HWND hwndDlg
)
312 /* open DirectPlay8 key */
313 result
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, L
"SOFTWARE\\Microsoft\\DirectPlay8\\Service Providers", 0, KEY_READ
, &hKey
);
314 if (result
!= ERROR_SUCCESS
)
317 hDlgCtrl
= GetDlgItem(hwndDlg
, IDC_LIST_PROVIDER
);
318 /* initialize list ctrl */
319 InitListViewColumns(hDlgCtrl
);
321 /* enumerate providers */
322 result
= EnumerateServiceProviders(hKey
, hDlgCtrl
, DirectPlay8SP
);
327 /* open DirectPlay key */
328 result
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, L
"SOFTWARE\\Microsoft\\DirectPlay\\Service Providers", 0, KEY_READ
, &hKey
);
329 if (result
!= ERROR_SUCCESS
)
332 /* enumerate providers */
333 result
= EnumerateServiceProviders(hKey
, hDlgCtrl
, DirectPlaySP
);
338 NetworkPageWndProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
340 UNREFERENCED_PARAMETER(lParam
);
341 UNREFERENCED_PARAMETER(wParam
);
345 SetWindowPos(hDlg
, NULL
, 10, 32, 0, 0, SWP_NOACTIVATE
| SWP_NOOWNERZORDER
| SWP_NOSIZE
| SWP_NOZORDER
);
346 InitializeDirectPlayDialog(hDlg
);