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 Item
.iItem
= SendMessageW(hDlgCtrl
, LVM_INSERTITEM
, 0, (LPARAM
)&Item
);
209 LoadStringW(hInst
, IDS_REG_FAIL
, szResult
, sizeof(szResult
)/sizeof(WCHAR
));
210 szResult
[(sizeof(szResult
)/sizeof(WCHAR
))-1] = L
'\0';
211 SendMessageW(hDlgCtrl
, LVM_SETITEM
, 0, (LPARAM
)&Item
);
217 dwName
= sizeof(szName
) / sizeof(WCHAR
);
218 result
= RegEnumKeyEx(hKey
, dwIndex
, szName
, &dwName
, NULL
, NULL
, NULL
, NULL
);
219 if (result
== ERROR_SUCCESS
)
221 szName
[(sizeof(szName
)/sizeof(WCHAR
))-1] = L
'\0';
223 ProviderIndex
= UINT_MAX
;
224 if (GetRegValue(hKey
, szName
, L
"GUID", REG_SZ
, szGUID
, sizeof(szGUID
)))
225 ProviderIndex
= FindProviderIndex(szGUID
, PreDefProviders
);
227 if (ProviderIndex
== UINT_MAX
)
229 /* a custom service provider was found */
230 Item
.iItem
= ListView_GetItemCount(hDlgCtrl
);
233 * on Windows Vista we need to use RegLoadMUIString which is not available for older systems
235 if (!GetRegValue(hKey
, szName
, L
"Friendly Name", REG_SZ
, szResult
, sizeof(szResult
)))
236 if (!GetRegValue(hKey
, szName
, L
"DescriptionW", REG_SZ
, szResult
, sizeof(szResult
)))
239 /* insert the new provider */
241 lResult
= SendMessageW(hDlgCtrl
, LVM_INSERTITEM
, 0, (LPARAM
)&Item
);
243 ProviderIndex
= lResult
- ItemCount
;
247 /* check if the 'Path' key is available */
248 if (!GetRegValue(hKey
, szName
, L
"Path", REG_SZ
, szResult
, sizeof(szResult
)))
250 /* retrieve the path by lookup the CLSID */
251 wcscpy(szTemp
, L
"CLSID\\");
252 wcscpy(&szTemp
[6], szGUID
);
253 wcscpy(&szTemp
[44], L
"\\InProcServer32");
254 if (!GetRegValue(HKEY_CLASSES_ROOT
, szTemp
, NULL
, REG_SZ
, szResult
, sizeof(szResult
)))
257 ProviderIndex
= UINT_MAX
;
262 /* insert path name */
264 Item
.iItem
= ProviderIndex
+ ItemCount
;
265 SendMessageW(hDlgCtrl
, LVM_SETITEM
, 0, (LPARAM
)&Item
);
266 /* retrieve file version */
267 if (!GetFileVersion(szResult
, szTemp
, sizeof(szTemp
)/sizeof(WCHAR
)))
270 LoadStringW(hInst
, IDS_VERSION_UNKNOWN
, szTemp
, sizeof(szTemp
)/sizeof(WCHAR
));
271 szTemp
[(sizeof(szTemp
)/sizeof(WCHAR
))-1] = L
'\0';
274 Item
.pszText
= szTemp
;
275 SendMessageW(hDlgCtrl
, LVM_SETITEM
, 0, (LPARAM
)&Item
);
276 Item
.pszText
= szResult
;
279 if (ProviderIndex
!= UINT_MAX
)
281 RegProviders
|= (1 << ProviderIndex
);
283 LoadStringW(hInst
, IDS_REG_SUCCESS
, szResult
, sizeof(szResult
));
286 Item
.iItem
= ProviderIndex
+ ItemCount
;
287 szResult
[(sizeof(szResult
)/sizeof(WCHAR
))-1] = L
'\0';
288 SendMessageW(hDlgCtrl
, LVM_SETITEM
, 0, (LPARAM
)&Item
);
292 }while(result
!= ERROR_NO_MORE_ITEMS
);
294 /* check if all providers have been registered */
295 // if (RegProviders == 15)
304 InitializeDirectPlayDialog(HWND hwndDlg
)
310 /* open DirectPlay8 key */
311 result
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, L
"SOFTWARE\\Microsoft\\DirectPlay8\\Service Providers", 0, KEY_READ
, &hKey
);
312 if (result
!= ERROR_SUCCESS
)
315 hDlgCtrl
= GetDlgItem(hwndDlg
, IDC_LIST_PROVIDER
);
316 /* initialize list ctrl */
317 InitListViewColumns(hDlgCtrl
);
319 /* enumerate providers */
320 result
= EnumerateServiceProviders(hKey
, hDlgCtrl
, DirectPlay8SP
);
325 /* open DirectPlay key */
326 result
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, L
"SOFTWARE\\Microsoft\\DirectPlay\\Service Providers", 0, KEY_READ
, &hKey
);
327 if (result
!= ERROR_SUCCESS
)
330 /* enumerate providers */
331 EnumerateServiceProviders(hKey
, hDlgCtrl
, DirectPlaySP
);
336 NetworkPageWndProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
338 UNREFERENCED_PARAMETER(lParam
);
339 UNREFERENCED_PARAMETER(wParam
);
343 SetWindowPos(hDlg
, NULL
, 10, 32, 0, 0, SWP_NOACTIVATE
| SWP_NOOWNERZORDER
| SWP_NOSIZE
| SWP_NOZORDER
);
344 InitializeDirectPlayDialog(hDlg
);