ReactOS  0.4.12-dev-102-g4b7f1e0
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.

Referenced by InitializeDirectPlayDialog().

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;
190  LVITEMW Item;
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 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
#define IDS_VERSION_UNKNOWN
Definition: resource.h:115
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ZeroMemory
Definition: winbase.h:1635
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
BOOL GetFileVersion(LPCWSTR szAppName, WCHAR *szVer, DWORD szVerSize)
Definition: network.c:105
#define LVIF_TEXT
Definition: commctrl.h:2279
BOOL GetRegValue(HKEY hBaseKey, LPWSTR SubKey, LPWSTR ValueName, DWORD Type, LPWSTR Result, DWORD Size)
Definition: system.c:15
long LONG
Definition: pedump.c:60
LONG_PTR LPARAM
Definition: windef.h:208
#define LVM_INSERTITEM
Definition: commctrl.h:2376
int iSubItem
Definition: commctrl.h:2332
#define IDS_REG_FAIL
Definition: resource.h:139
UINT FindProviderIndex(LPCWSTR szGuid, DIRECTPLAY_GUID *PreDefProviders)
Definition: network.c:93
smooth NULL
Definition: ftsmooth.c:416
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2277
LPWSTR pszText
Definition: commctrl.h:2335
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
UINT mask
Definition: commctrl.h:2330
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1087
#define IDS_REG_SUCCESS
Definition: resource.h:140
#define RegEnumKeyEx
Definition: winreg.h:510
#define UINT_MAX
Definition: limits.h:41
HINSTANCE hInst
Definition: dxdiag.c:13
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LVM_SETITEM
Definition: commctrl.h:2369
static const WCHAR szName[]
Definition: msipriv.h:1194
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
LONG_PTR LRESULT
Definition: windef.h:209
GLuint64EXT * result
Definition: glext.h:11304
#define REG_SZ
Definition: layer.c:22

◆ FindProviderIndex()

UINT FindProviderIndex ( LPCWSTR  szGuid,
DIRECTPLAY_GUID PreDefProviders 
)

Definition at line 93 of file network.c.

Referenced by EnumerateServiceProviders().

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 GUID * Guid
Definition: apphelp.c:93
unsigned int UINT
Definition: ndis.h:50
static const UCHAR Index[8]
Definition: usbohci.c:18
_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)
#define UINT_MAX
Definition: limits.h:41
static const WCHAR szGuid[]
Definition: rtlstr.c:1892

◆ GetFileVersion()

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

Definition at line 105 of file network.c.

Referenced by DriverFilesCallback(), and EnumerateServiceProviders().

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 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define MAKELCID(lgid, srtid)
#define TRUE
Definition: types.h:120
#define LOCALE_SLANGUAGE
Definition: winnls.h:26
__wchar_t WCHAR
Definition: xmlstorage.h:180
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:807
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR lang[]
Definition: wbemdisp.c:252
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
#define SORT_DEFAULT
unsigned int UINT
Definition: ndis.h:50
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1087
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:616
TCHAR szAppName[128]
Definition: solitaire.cpp:16
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:850
#define HeapFree(x, y, z)
Definition: compat.h:394
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1054

◆ InitializeDirectPlayDialog()

static void InitializeDirectPlayDialog ( HWND  hwndDlg)
static

Definition at line 306 of file network.c.

Referenced by NetworkPageWndProc().

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 */
326  result = EnumerateServiceProviders(hKey, hDlgCtrl, DirectPlay8SP);
327  RegCloseKey(hKey);
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 */
337  EnumerateServiceProviders(hKey, hDlgCtrl, DirectPlaySP);
338  RegCloseKey(hKey);
339 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2704
#define IDC_LIST_PROVIDER
Definition: resource.h:95
static DIRECTPLAY_GUID DirectPlay8SP[]
Definition: network.c:26
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
static VOID InitListViewColumns(HWND hDlgCtrl)
Definition: network.c:68
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define LVM_SETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2694
static DIRECTPLAY_GUID DirectPlaySP[]
Definition: network.c:46
static BOOL EnumerateServiceProviders(HKEY hKey, HWND hDlgCtrl, DIRECTPLAY_GUID *PreDefProviders)
Definition: network.c:179
static const WCHAR L[]
Definition: oid.c:1087
#define SendMessage
Definition: winuser.h:5709
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
GLuint64EXT * result
Definition: glext.h:11304
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ InitListViewColumns()

static VOID InitListViewColumns ( HWND  hDlgCtrl)
static

Definition at line 68 of file network.c.

Referenced by InitializeDirectPlayDialog().

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 LVCF_WIDTH
Definition: commctrl.h:2557
#define LVCF_TEXT
Definition: commctrl.h:2558
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define LVCFMT_LEFT
Definition: commctrl.h:2568
#define ZeroMemory
Definition: winbase.h:1635
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
#define LVCF_SUBITEM
Definition: commctrl.h:2559
static const WCHAR szText[]
Definition: dialog.c:139
#define LVM_INSERTCOLUMNW
Definition: commctrl.h:2602
LONG_PTR LPARAM
Definition: windef.h:208
#define IDS_DIRECTPLAY_COL_NAME1
Definition: resource.h:127
static const UCHAR Index[8]
Definition: usbohci.c:18
LPWSTR pszText
Definition: commctrl.h:2537
static const WCHAR L[]
Definition: oid.c:1087
#define LVCF_FMT
Definition: commctrl.h:2556
HINSTANCE hInst
Definition: dxdiag.c:13
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ NetworkPageWndProc()

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

Definition at line 342 of file network.c.

Referenced by InitializeTabCtrl().

343 {
346  switch (message) {
347  case WM_INITDIALOG:
348  {
351  return TRUE;
352  }
353  }
354 
355  return FALSE;
356 }
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define SWP_NOZORDER
Definition: winuser.h:1232
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define SWP_NOSIZE
Definition: winuser.h:1230
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
static void InitializeDirectPlayDialog(HWND hwndDlg)
Definition: network.c:306
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define SWP_NOOWNERZORDER
Definition: winuser.h:1234

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
static const WCHAR L[]
Definition: oid.c:1087
#define IDS_DIRECTPLAY8_IPXSP
Definition: resource.h:133

Definition at line 26 of file network.c.

◆ 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_MODEMCONN
Definition: resource.h:137
#define IDS_DIRECTPLAY_SERIALCONN
Definition: resource.h:138
#define IDS_DIRECTPLAY_IPXCONN
Definition: resource.h:136
static const WCHAR L[]
Definition: oid.c:1087
#define IDS_DIRECTPLAY_TCPCONN
Definition: resource.h:135

Definition at line 46 of file network.c.