ReactOS 0.4.15-dev-7958-gcd0bb1a
network.c File Reference
#include "precomp.h"
#include <winver.h>
Include dependency graph for network.c:

Go to the source code of this file.

Classes

struct  DIRECTPLAY_GUID
 
struct  _LANGANDCODEPAGE_
 

Typedefs

typedef struct _LANGANDCODEPAGE_ LANGANDCODEPAGE
 
typedef struct _LANGANDCODEPAGE_LPLANGANDCODEPAGE
 

Functions

static VOID InitListViewColumns (HWND hDlgCtrl)
 
UINT FindProviderIndex (LPCWSTR szGuid, DIRECTPLAY_GUID *PreDefProviders)
 
BOOL GetFileVersion (LPCWSTR szAppName, WCHAR *szVer, DWORD szVerSize)
 
static BOOL EnumerateServiceProviders (HKEY hKey, HWND hDlgCtrl, DIRECTPLAY_GUID *PreDefProviders)
 
static void InitializeDirectPlayDialog (HWND hwndDlg)
 
INT_PTR CALLBACK NetworkPageWndProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 

Variables

static DIRECTPLAY_GUID DirectPlay8SP []
 
static DIRECTPLAY_GUID DirectPlaySP []
 

Typedef Documentation

◆ LANGANDCODEPAGE

◆ LPLANGANDCODEPAGE

Function Documentation

◆ EnumerateServiceProviders()

static BOOL EnumerateServiceProviders ( HKEY  hKey,
HWND  hDlgCtrl,
DIRECTPLAY_GUID PreDefProviders 
)
static

Definition at line 179 of file network.c.

180{
181 DWORD dwIndex = 0;
182 LONG result;
183 WCHAR szName[50];
184 WCHAR szGUID[40];
185 WCHAR szTemp[63];
186 WCHAR szResult[MAX_PATH+20] = {0};
187 DWORD RegProviders = 0;
188 DWORD ProviderIndex;
189 DWORD dwName;
191 INT ItemCount;
192 LRESULT lResult;
193
194
195 ItemCount = ListView_GetItemCount(hDlgCtrl);
196 ZeroMemory(&Item, sizeof(LVITEMW));
197 Item.mask = LVIF_TEXT;
198 Item.pszText = szResult;
199 Item.iItem = ItemCount;
200 /* insert all predefined items first */
201 for(dwIndex = 0; dwIndex < 4; dwIndex++)
202 {
203 Item.iItem = ItemCount + dwIndex;
204 Item.iSubItem = 0;
205 szResult[0] = L'\0';
206 LoadStringW(hInst, PreDefProviders[dwIndex].ResourceID, szResult, sizeof(szResult)/sizeof(WCHAR));
207 szResult[(sizeof(szResult)/sizeof(WCHAR))-1] = L'\0';
208 Item.iItem = SendMessageW(hDlgCtrl, LVM_INSERTITEM, 0, (LPARAM)&Item);
209 Item.iSubItem = 1;
210 szResult[0] = L'\0';
211 LoadStringW(hInst, IDS_REG_FAIL, szResult, sizeof(szResult)/sizeof(WCHAR));
212 szResult[(sizeof(szResult)/sizeof(WCHAR))-1] = L'\0';
213 SendMessageW(hDlgCtrl, LVM_SETITEM, 0, (LPARAM)&Item);
214 }
215
216 dwIndex = 0;
217 do
218 {
219 dwName = sizeof(szName) / sizeof(WCHAR);
220 result = RegEnumKeyEx(hKey, dwIndex, szName, &dwName, NULL, NULL, NULL, NULL);
221 if (result == ERROR_SUCCESS)
222 {
223 szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
224
225 ProviderIndex = UINT_MAX;
226 if (GetRegValue(hKey, szName, L"GUID", REG_SZ, szGUID, sizeof(szGUID)))
227 ProviderIndex = FindProviderIndex(szGUID, PreDefProviders);
228
229 if (ProviderIndex == UINT_MAX)
230 {
231 /* a custom service provider was found */
232 Item.iItem = ListView_GetItemCount(hDlgCtrl);
233
234 /* FIXME
235 * on Windows Vista we need to use RegLoadMUIString which is not available for older systems
236 */
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)))
239 szResult[0] = L'\0';
240
241 /* insert the new provider */
242 Item.iSubItem = 0;
243 lResult = SendMessageW(hDlgCtrl, LVM_INSERTITEM, 0, (LPARAM)&Item);
244 /* adjust index */
245 ProviderIndex = lResult - ItemCount;
246 }
247
248 szResult[0] = L'\0';
249 /* check if the 'Path' key is available */
250 if (!GetRegValue(hKey, szName, L"Path", REG_SZ, szResult, sizeof(szResult)))
251 {
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)))
257 {
258 szResult[0] = L'\0';
259 ProviderIndex = UINT_MAX;
260 }
261 }
262 if (szResult[0])
263 {
264 /* insert path name */
265 Item.iSubItem = 2;
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)))
270 {
271 szTemp[0] = L'\0';
272 LoadStringW(hInst, IDS_VERSION_UNKNOWN, szTemp, sizeof(szTemp)/sizeof(WCHAR));
273 szTemp[(sizeof(szTemp)/sizeof(WCHAR))-1] = L'\0';
274 }
275 Item.iSubItem = 3;
276 Item.pszText = szTemp;
277 SendMessageW(hDlgCtrl, LVM_SETITEM, 0, (LPARAM)&Item);
278 Item.pszText = szResult;
279 }
280
281 if (ProviderIndex != UINT_MAX)
282 {
283 RegProviders |= (1 << ProviderIndex);
284 szResult[0] = L'\0';
285 LoadStringW(hInst, IDS_REG_SUCCESS, szResult, sizeof(szResult) / sizeof(WCHAR));
286 Item.iSubItem = 1;
287
288 Item.iItem = ProviderIndex + ItemCount;
289 szResult[(sizeof(szResult)/sizeof(WCHAR))-1] = L'\0';
290 SendMessageW(hDlgCtrl, LVM_SETITEM, 0, (LPARAM)&Item);
291 }
292 }
293 dwIndex++;
294 }while(result != ERROR_NO_MORE_ITEMS);
295
296 /* check if all providers have been registered */
297// if (RegProviders == 15)
298 return TRUE;
299 return FALSE;
300}
BOOL GetFileVersion(LPCWSTR szAppName, WCHAR *szVer, DWORD szVerSize)
Definition: network.c:105
UINT FindProviderIndex(LPCWSTR szGuid, DIRECTPLAY_GUID *PreDefProviders)
Definition: network.c:93
BOOL GetRegValue(HKEY hBaseKey, LPWSTR SubKey, LPWSTR ValueName, DWORD Type, LPWSTR Result, DWORD Size)
Definition: system.c:15
#define IDS_VERSION_UNKNOWN
Definition: resource.h:115
#define IDS_REG_SUCCESS
Definition: resource.h:140
#define IDS_REG_FAIL
Definition: resource.h:139
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define MAX_PATH
Definition: compat.h:34
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLuint64EXT * result
Definition: glext.h:11304
#define UINT_MAX
Definition: limits.h:41
#define REG_SZ
Definition: layer.c:22
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
static const WCHAR szName[]
Definition: powrprof.c:45
#define LVM_SETITEM
Definition: commctrl.h:2399
#define LVM_INSERTITEM
Definition: commctrl.h:2406
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2307
#define LVIF_TEXT
Definition: commctrl.h:2309
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
int32_t INT
Definition: typedefs.h:58
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
#define ZeroMemory
Definition: winbase.h:1712
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
#define RegEnumKeyEx
Definition: winreg.h:510
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by InitializeDirectPlayDialog().

◆ FindProviderIndex()

UINT FindProviderIndex ( LPCWSTR  szGuid,
DIRECTPLAY_GUID PreDefProviders 
)

Definition at line 93 of file network.c.

94{
95 UINT Index;
96 for(Index = 0; Index < 4; Index++)
97 {
98 if (!wcsncmp(PreDefProviders[Index].Guid, szGuid, 40))
99 return Index;
100 }
101 return UINT_MAX;
102}
static const WCHAR szGuid[]
Definition: rtlstr.c:1892
unsigned int UINT
Definition: ndis.h:50
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762

Referenced by EnumerateServiceProviders().

◆ GetFileVersion()

BOOL GetFileVersion ( LPCWSTR  szAppName,
WCHAR szVer,
DWORD  szVerSize 
)

Definition at line 105 of file network.c.

106{
107 UINT VerSize;
108 DWORD DummyHandle;
109 LPVOID pBuf;
110 WORD lang = 0;
111 WORD code = 0;
112 LPLANGANDCODEPAGE lplangcode;
113 WCHAR szBuffer[100];
114 WCHAR * pResult;
115 BOOL bResult = FALSE;
116 BOOL bVer;
117
118 static const WCHAR wFormat[] = L"\\StringFileInfo\\%04x%04x\\FileVersion";
119 static const WCHAR wTranslation[] = L"VarFileInfo\\Translation";
120
121 /* query version info size */
122 VerSize = GetFileVersionInfoSizeW(szAppName, &DummyHandle);
123 if (!VerSize)
124 return FALSE;
125
126
127 /* allocate buffer */
128 pBuf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, VerSize);
129 if (!pBuf)
130 return FALSE;
131
132
133 /* query version info */
134 if(!GetFileVersionInfoW(szAppName, 0, VerSize, pBuf))
135 {
136 HeapFree(GetProcessHeap(), 0, pBuf);
137 return FALSE;
138 }
139
140 /* query lang code */
141 if(VerQueryValueW(pBuf, wTranslation, (LPVOID *)&lplangcode, &VerSize))
142 {
143 /* FIXME find language from current locale / if not available,
144 * default to english
145 * for now default to first available language
146 */
147 lang = lplangcode->lang;
148 code = lplangcode->code;
149 }
150 /* set up format */
151 wsprintfW(szBuffer, wFormat, lang, code);
152 /* query manufacturer */
153 pResult = NULL;
154 bVer = VerQueryValueW(pBuf, szBuffer, (LPVOID *)&pResult, &VerSize);
155
156 if (VerSize < szVerSize && bVer && pResult)
157 {
158 wcscpy(szVer, pResult);
159 pResult = wcschr(szVer, L' ');
160 if (pResult)
161 {
162 /* cut off build info */
163 VerSize = (pResult - szVer);
164 }
165 if (GetLocaleInfoW(MAKELCID(lang, SORT_DEFAULT), LOCALE_SLANGUAGE, &szVer[VerSize], szVerSize-VerSize))
166 {
167 szVer[VerSize-1] = L' ';
168 szVer[szVerSize-1] = L'\0';
169 }
170 bResult = TRUE;
171 }
172
173 HeapFree(GetProcessHeap(), 0, pBuf);
174 return bResult;
175}
#define wcschr
Definition: compat.h:17
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:845
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1049
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:611
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned short WORD
Definition: ntddk_ex.h:93
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1108
#define SORT_DEFAULT
#define MAKELCID(lgid, srtid)
TCHAR szAppName[128]
Definition: solitaire.cpp:18
Definition: inflate.c:139
static const WCHAR lang[]
Definition: wbemdisp.c:287
#define LOCALE_SLANGUAGE
Definition: winnls.h:26
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)

Referenced by DriverFilesCallback(), and EnumerateServiceProviders().

◆ InitializeDirectPlayDialog()

static void InitializeDirectPlayDialog ( HWND  hwndDlg)
static

Definition at line 306 of file network.c.

307{
308 HKEY hKey;
309 LONG result;
310 HWND hDlgCtrl;
311
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)
315 return;
316
317 hDlgCtrl = GetDlgItem(hwndDlg, IDC_LIST_PROVIDER);
318
319 /* Highlights the entire row instead of just the selected item in the first column */
321
322 /* initialize list ctrl */
323 InitListViewColumns(hDlgCtrl);
324
325 /* enumerate providers */
328 if (!result)
329 return;
330
331 /* open DirectPlay key */
332 result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\DirectPlay\\Service Providers", 0, KEY_READ, &hKey);
333 if (result != ERROR_SUCCESS)
334 return;
335
336 /* enumerate providers */
339}
static BOOL EnumerateServiceProviders(HKEY hKey, HWND hDlgCtrl, DIRECTPLAY_GUID *PreDefProviders)
Definition: network.c:179
static DIRECTPLAY_GUID DirectPlay8SP[]
Definition: network.c:26
static VOID InitListViewColumns(HWND hDlgCtrl)
Definition: network.c:68
static DIRECTPLAY_GUID DirectPlaySP[]
Definition: network.c:46
#define IDC_LIST_PROVIDER
Definition: resource.h:95
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
#define KEY_READ
Definition: nt_native.h:1023
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2734
#define LVM_SETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2724
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define SendMessage
Definition: winuser.h:5843

Referenced by NetworkPageWndProc().

◆ InitListViewColumns()

static VOID InitListViewColumns ( HWND  hDlgCtrl)
static

Definition at line 68 of file network.c.

69{
70 WCHAR szText[256];
71 LVCOLUMNW lvcolumn;
72 INT Index;
73
74 ZeroMemory(&lvcolumn, sizeof(LVCOLUMNW));
75 lvcolumn.pszText = szText;
77 lvcolumn.fmt = LVCFMT_LEFT;
78 lvcolumn.cx = 200;
79
80 for(Index = 0; Index < 4; Index++)
81 {
82 szText[0] = L'\0';
83 LoadStringW(hInst, IDS_DIRECTPLAY_COL_NAME1 + Index, szText, sizeof(szText) / sizeof(WCHAR));
84 szText[(sizeof(szText) / sizeof(WCHAR))-1] = L'\0';
85 if (Index)
86 lvcolumn.cx = 98;
87 if (SendMessageW(hDlgCtrl, LVM_INSERTCOLUMNW, Index, (LPARAM)&lvcolumn) == -1)
88 return;
89 }
90}
#define IDS_DIRECTPLAY_COL_NAME1
Definition: resource.h:127
#define LVCF_WIDTH
Definition: commctrl.h:2587
#define LVM_INSERTCOLUMNW
Definition: commctrl.h:2632
#define LVCF_FMT
Definition: commctrl.h:2586
#define LVCF_SUBITEM
Definition: commctrl.h:2589
#define LVCFMT_LEFT
Definition: commctrl.h:2598
#define LVCF_TEXT
Definition: commctrl.h:2588
LPWSTR pszText
Definition: commctrl.h:2567

Referenced by InitializeDirectPlayDialog().

◆ NetworkPageWndProc()

INT_PTR CALLBACK NetworkPageWndProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 342 of file network.c.

343{
346 switch (message) {
347 case WM_INITDIALOG:
348 {
351 return TRUE;
352 }
353 }
354
355 return FALSE;
356}
static void InitializeDirectPlayDialog(HWND hwndDlg)
Definition: network.c:306
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
Definition: tftpd.h:60
#define SWP_NOACTIVATE
Definition: winuser.h:1242
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOSIZE
Definition: winuser.h:1245
#define WM_INITDIALOG
Definition: winuser.h:1739
#define SWP_NOOWNERZORDER
Definition: winuser.h:1249
#define SWP_NOZORDER
Definition: winuser.h:1247

Referenced by InitializeTabCtrl().

Variable Documentation

◆ DirectPlay8SP

DIRECTPLAY_GUID DirectPlay8SP[]
static
Initial value:
=
{
{
L"{6D4A3650-628D-11D2-AE0F-006097B01411}",
},
{
L"{743B5D60-628D-11D2-AE0F-006097B01411}",
},
{
L"{53934290-628D-11D2-AE0F-006097B01411}",
},
{
L"{EBFE7BA0-628D-11D2-AE0F-006097B01411}",
}
}
#define IDS_DIRECTPLAY8_SERIALSP
Definition: resource.h:132
#define IDS_DIRECTPLAY8_MODEMSP
Definition: resource.h:131
#define IDS_DIRECTPLAY8_TCPSP
Definition: resource.h:134
#define IDS_DIRECTPLAY8_IPXSP
Definition: resource.h:133

Definition at line 26 of file network.c.

Referenced by InitializeDirectPlayDialog().

◆ DirectPlaySP

DIRECTPLAY_GUID DirectPlaySP[]
static
Initial value:
=
{
{
L"{36E95EE0-8577-11cf-960C-0080C7534E82}",
},
{
L"685BC400-9D2C-11cf-A9CD-00AA006886E3",
},
{
L"{44EAA760-CB68-11cf-9C4E-00A0C905425E}",
},
{
L"{0F1D6860-88D9-11cf-9C4E-00A0C905425E}",
}
}
#define IDS_DIRECTPLAY_IPXCONN
Definition: resource.h:136
#define IDS_DIRECTPLAY_MODEMCONN
Definition: resource.h:137
#define IDS_DIRECTPLAY_SERIALCONN
Definition: resource.h:138
#define IDS_DIRECTPLAY_TCPCONN
Definition: resource.h:135

Definition at line 46 of file network.c.

Referenced by InitializeDirectPlayDialog().