ReactOS  0.4.15-dev-509-g96a357b
netid.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <winreg.h>
#include <windns.h>
#include <lm.h>
#include <prsht.h>
#include "resource.h"
Include dependency graph for netid.c:

Go to the source code of this file.

Classes

struct  _NETIDDATA
 

Macros

#define WIN32_NO_STATUS
 
#define MAX_COMPUTERDESCRIPTION_LENGTH   255
 
#define MAX_HOSTNAME_LENGTH   63
 
#define MAX_DOMAINNAME_LENGTH   255
 

Typedefs

typedef struct _NETIDDATA NETIDDATA
 
typedef struct _NETIDDATAPNETIDDATA
 

Functions

static INT FormatMessageBox (HWND hDlg, UINT uType, DWORD dwMessage,...)
 
static BOOL GetComputerNames (PNETIDDATA pNetIdData)
 
static BOOL IsUserAdmin (VOID)
 
static BOOL IsValidDomainName (HWND hDlg, UINT uId)
 
static INT_PTR CALLBACK DNSSuffixPropDlgProc (HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
 
static VOID SetRadioBtnState (HWND hDlg, BOOL IsDomain)
 
static BOOL IsValidComputerName (HWND hDlg, UINT uId)
 
static VOID SetFullComputerName (HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
 
static VOID UpdateFullComputerName (HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
 
static VOID UpdateNetbiosName (HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
 
static VOID CheckForChangedNames (_In_ HWND hwndDlg, _In_ PNETIDDATA pNetIdData)
 
static VOID NetworkDlg_OnInitDialog (HWND hDlg, PNETIDDATA pNetIdData)
 
static BOOL NetworkDlg_OnOK (HWND hDlg, PNETIDDATA pNetIdData)
 
static INT_PTR CALLBACK NetworkPropDlgProc (HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
 
static VOID NetIDPage_OnInitDialog (HWND hwndDlg, PNETIDDATA pNetIdData)
 
static LONG NetIDPage_OnApply (HWND hwndDlg)
 
static INT_PTR CALLBACK NetIDPageProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
HPROPSHEETPAGE WINAPI CreateNetIDPropertyPage (VOID)
 
BOOL WINAPI DllMain (IN HINSTANCE hinstDLL, IN DWORD dwReason, IN LPVOID lpvReserved)
 

Variables

static HINSTANCE hDllInstance
 

Macro Definition Documentation

◆ MAX_COMPUTERDESCRIPTION_LENGTH

#define MAX_COMPUTERDESCRIPTION_LENGTH   255

Definition at line 24 of file netid.c.

◆ MAX_DOMAINNAME_LENGTH

#define MAX_DOMAINNAME_LENGTH   255

Definition at line 26 of file netid.c.

◆ MAX_HOSTNAME_LENGTH

#define MAX_HOSTNAME_LENGTH   63

Definition at line 25 of file netid.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 11 of file netid.c.

Typedef Documentation

◆ NETIDDATA

◆ PNETIDDATA

Function Documentation

◆ CheckForChangedNames()

static VOID CheckForChangedNames ( _In_ HWND  hwndDlg,
_In_ PNETIDDATA  pNetIdData 
)
static

Definition at line 446 of file netid.c.

449 {
450  INT nShow = SW_HIDE;
451 
452  if ((wcsicmp(pNetIdData->szOldHostName, pNetIdData->szHostName) != 0) ||
453  (wcsicmp(pNetIdData->szOldDomainName, pNetIdData->szDomainName) != 0))
454  {
455  nShow = SW_SHOW;
456  }
457 
458  ShowWindow(GetDlgItem(hwndDlg, IDC_RESTARTICON), nShow);
459  ShowWindow(GetDlgItem(hwndDlg, IDC_RESTARTTEXT), nShow);
460 }
#define SW_HIDE
Definition: winuser.h:762
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int32_t INT
Definition: typedefs.h:57
#define IDC_RESTARTTEXT
Definition: resource.h:22
#define SW_SHOW
Definition: winuser.h:769
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_RESTARTICON
Definition: resource.h:21
#define wcsicmp
Definition: string.h:1152

Referenced by NetIDPageProc().

◆ CreateNetIDPropertyPage()

HPROPSHEETPAGE WINAPI CreateNetIDPropertyPage ( VOID  )

Definition at line 814 of file netid.c.

815 {
816  PROPSHEETPAGE psp = {0};
817 
818  psp.dwSize = sizeof(psp);
819  psp.dwFlags = PSP_DEFAULT;
820  psp.hInstance = hDllInstance;
821  psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGECOMPUTER);
822  psp.pfnDlgProc = NetIDPageProc;
823 
824  return CreatePropertySheetPage(&psp);
825 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IDD_PROPPAGECOMPUTER
Definition: resource.h:12
static HINSTANCE hDllInstance
Definition: netid.c:45
#define CreatePropertySheetPage
Definition: prsht.h:399
#define PSP_DEFAULT
Definition: prsht.h:22
static INT_PTR CALLBACK NetIDPageProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: netid.c:743
#define PROPSHEETPAGE
Definition: prsht.h:389

◆ DllMain()

BOOL WINAPI DllMain ( IN HINSTANCE  hinstDLL,
IN DWORD  dwReason,
IN LPVOID  lpvReserved 
)

@DllMain

Core routine of the Utility Manager's library.

Parameters
[in]hDllInstanceThe entry point instance of the library.
[in]fdwReasonThe reason argument to indicate the motive DllMain is being called.
[in]lpvReservedReserved.
Returns
Returns TRUE when main call initialization has succeeded, FALSE otherwise.

Definition at line 828 of file netid.c.

831 {
832  switch (dwReason)
833  {
834  case DLL_PROCESS_ATTACH:
835  hDllInstance = hinstDLL;
836  DisableThreadLibraryCalls(hinstDLL);
837  break;
838  }
839 
840  return TRUE;
841 }
#define TRUE
Definition: types.h:120
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
DWORD dwReason
Definition: misc.cpp:154
static HINSTANCE hDllInstance
Definition: netid.c:45

◆ DNSSuffixPropDlgProc()

static INT_PTR CALLBACK DNSSuffixPropDlgProc ( HWND  hDlg,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 264 of file netid.c.

265 {
266  PNETIDDATA pNetIdData;
267 
268  pNetIdData = (PNETIDDATA)GetWindowLongPtr(hDlg, DWLP_USER);
269 
270  switch (Msg)
271  {
272  case WM_INITDIALOG:
273  pNetIdData = (PNETIDDATA)lParam;
274  if (pNetIdData != NULL)
275  {
276  SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pNetIdData);
277 
278  SetDlgItemTextW(hDlg, 1011, pNetIdData->szDomainName);
279  SendDlgItemMessage(hDlg, 115, BM_SETCHECK, (WPARAM)pNetIdData->bSyncDomainWithMembership, 0);
280  SetDlgItemTextW(hDlg, 1013, pNetIdData->szComputerName);
282  }
283  return TRUE;
284 
285  case WM_COMMAND:
286  switch (LOWORD(wParam))
287  {
288  case 115:
289  if (HIWORD(wParam) == BN_CLICKED)
290  {
291  EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
293  }
294  break;
295 
296  case 1011:
297  if (HIWORD(wParam) == EN_CHANGE)
298  {
299  EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
300  pNetIdData->bDomainNameChanged = TRUE;
301  }
302  break;
303 
304  case IDOK:
305  if (!IsValidDomainName(hDlg, 1011))
306  {
307  SetFocus(GetDlgItem(hDlg, 1011));
308  break;
309  }
310 
311  if (pNetIdData->bDomainNameChanged)
312  GetDlgItemTextW(hDlg, 1011, pNetIdData->szDomainName, ARRAYSIZE(pNetIdData->szDomainName));
313 
314  if (pNetIdData->bSyncDomainWithMembershipChanged)
315  {
316  if (SendDlgItemMessage(hDlg, 115, BM_GETCHECK, 0, 0) == BST_CHECKED)
317  pNetIdData->bSyncDomainWithMembership = TRUE;
318  else
319  pNetIdData->bSyncDomainWithMembership = FALSE;
320  }
321 
322  EndDialog(hDlg, TRUE);
323  break;
324 
325  case IDCANCEL:
326  pNetIdData->bDomainNameChanged = FALSE;
328  EndDialog(hDlg, FALSE);
329  break;
330  }
331  break;
332  }
333 
334  return FALSE;
335 }
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2271
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HWND WINAPI SetFocus(_In_opt_ HWND)
struct @1604 Msg[]
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5817
BOOL bSyncDomainWithMembershipChanged
Definition: netid.c:40
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH+1]
Definition: netid.c:34
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
BOOL bDomainNameChanged
Definition: netid.c:39
smooth NULL
Definition: ftsmooth.c:416
#define BM_GETCHECK
Definition: winuser.h:1900
#define BM_SETCHECK
Definition: winuser.h:1903
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define BN_CLICKED
Definition: winuser.h:1907
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1722
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
struct _NETIDDATA * PNETIDDATA
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define BST_CHECKED
Definition: winuser.h:197
#define HIWORD(l)
Definition: typedefs.h:246
#define GetWindowLongPtr
Definition: treelist.c:73
BOOL bSyncDomainWithMembership
Definition: netid.c:35
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
static BOOL IsValidDomainName(HWND hDlg, UINT uId)
Definition: netid.c:223
WCHAR szDomainName[MAX_DOMAINNAME_LENGTH+1]
Definition: netid.c:32
#define EN_CHANGE
Definition: winuser.h:2004

Referenced by NetworkPropDlgProc().

◆ FormatMessageBox()

static INT FormatMessageBox ( HWND  hDlg,
UINT  uType,
DWORD  dwMessage,
  ... 
)
static

Definition at line 49 of file netid.c.

54 {
55  WCHAR szTitle[256], szMessage[256], szText[512];
56  va_list args = NULL;
57 
59 
60  LoadStringW(hDllInstance, dwMessage, szMessage, ARRAYSIZE(szMessage));
61 
62  va_start(args, dwMessage);
64  szMessage,
65  0,
66  0,
67  szText,
69  &args);
70  va_end(args);
71 
72  return MessageBoxW(hDlg, szText, szTitle, uType);
73 }
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:402
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
Definition: match.c:390
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define va_end(ap)
Definition: acmsvcex.h:90
static const WCHAR szText[]
Definition: dialog.c:139
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
static HINSTANCE hDllInstance
Definition: netid.c:45
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define va_start(ap, A)
Definition: acmsvcex.h:91

Referenced by IsValidComputerName(), and IsValidDomainName().

◆ GetComputerNames()

static BOOL GetComputerNames ( PNETIDDATA  pNetIdData)
static

Definition at line 77 of file netid.c.

79 {
81  DWORD dwSize;
82  DWORD dwError;
83 
85  L"SYSTEM\\CurrentControlSet\\Services\\TcpIp\\Parameters",
86  0,
88  &KeyHandle);
89  if (dwError == ERROR_SUCCESS)
90  {
91  dwSize = sizeof(pNetIdData->szHostName);
93  L"NV HostName",
94  0,
95  NULL,
96  (LPBYTE)&pNetIdData->szHostName,
97  &dwSize);
98 
99  dwSize = sizeof(pNetIdData->szOldHostName);
101  L"HostName",
102  0,
103  NULL,
104  (LPBYTE)&pNetIdData->szOldHostName,
105  &dwSize);
106 
107  dwSize = sizeof(pNetIdData->szDomainName);
109  L"NV Domain",
110  0,
111  NULL,
112  (LPBYTE)&pNetIdData->szDomainName,
113  &dwSize);
114 
115  dwSize = sizeof(pNetIdData->szOldDomainName);
117  L"Domain",
118  0,
119  NULL,
120  (LPBYTE)&pNetIdData->szOldDomainName,
121  &dwSize);
122 
123  dwSize = sizeof(pNetIdData->bSyncDomainWithMembership);
125  L"SyncDomainWithMembership",
126  0,
127  NULL,
128  (LPBYTE)&pNetIdData->bSyncDomainWithMembership,
129  &dwSize))
130  pNetIdData->bSyncDomainWithMembership = TRUE;
131 
133  }
134 
136  L"SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ComputerName",
137  0,
139  &KeyHandle);
140  if (dwError == ERROR_SUCCESS)
141  {
142  dwSize = sizeof(pNetIdData->szComputerName);
144  L"ComputerName",
145  0,
146  NULL,
147  (LPBYTE)&pNetIdData->szComputerName,
148  &dwSize);
149 
151  }
152 
153  if (NetGetJoinInformation(NULL, &pNetIdData->JoinName, &pNetIdData->JoinStatus) != NERR_Success)
154  {
155  pNetIdData->JoinName = NULL;
156  pNetIdData->JoinStatus = NetSetupUnknownStatus;
157  }
158 
159  return TRUE;
160 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
NETSETUP_JOIN_STATUS JoinStatus
Definition: netid.c:37
WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH+1]
Definition: netid.c:34
#define NERR_Success
Definition: lmerr.h:5
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
smooth NULL
Definition: ftsmooth.c:416
NET_API_STATUS WINAPI NetGetJoinInformation(_In_ LPCWSTR lpServer, _Out_ LPWSTR *lpNameBuffer, _Out_ PNETSETUP_JOIN_STATUS BufferType)
Definition: wksta_new.c:317
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
WCHAR szHostName[MAX_HOSTNAME_LENGTH+1]
Definition: netid.c:30
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
WCHAR szOldDomainName[MAX_DOMAINNAME_LENGTH+1]
Definition: netid.c:33
WCHAR szOldHostName[MAX_HOSTNAME_LENGTH+1]
Definition: netid.c:31
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
BOOL bSyncDomainWithMembership
Definition: netid.c:35
LPWSTR JoinName
Definition: netid.c:36
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
WCHAR szDomainName[MAX_DOMAINNAME_LENGTH+1]
Definition: netid.c:32
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by NetIDPageProc().

◆ IsUserAdmin()

static BOOL IsUserAdmin ( VOID  )
static

Definition at line 163 of file netid.c.

164 {
166  PSID pAdminsSid = NULL;
167  HANDLE hToken = NULL;
168  PTOKEN_GROUPS pGroups = NULL;
169  BOOL bIsAdmin = FALSE;
170  DWORD dwSize, i;
171 
173  DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0,
174  &pAdminsSid))
175  return FALSE;
176 
178  TOKEN_QUERY,
179  &hToken))
180  goto done;
181 
182  if (GetTokenInformation(hToken, TokenGroups, NULL, 0, &dwSize) ||
184  {
185  goto done;
186  }
187 
188  pGroups = HeapAlloc(GetProcessHeap(), 0, dwSize);
189  if (pGroups == NULL)
190  goto done;
191 
192  if (!GetTokenInformation(hToken,
193  TokenGroups,
194  pGroups,
195  dwSize,
196  &dwSize))
197  goto done;
198 
199  for (i = 0; i < pGroups->GroupCount; i++)
200  {
201  if (EqualSid(pGroups->Groups[i].Sid, pAdminsSid))
202  {
203  bIsAdmin = TRUE;
204  break;
205  }
206  }
207 
208 done:
209  if (pGroups != NULL)
210  HeapFree(GetProcessHeap(), 0, pGroups);
211 
212  if (hToken != NULL)
213  CloseHandle(hToken);
214 
215  if (pAdminsSid != NULL)
216  FreeSid(pAdminsSid);
217 
218  return bIsAdmin;
219 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:407
BOOL WINAPI EqualSid(PSID pSid1, PSID pSid2)
Definition: security.c:708
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:577
smooth NULL
Definition: ftsmooth.c:416
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:526
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:553
#define TOKEN_QUERY
Definition: setypes.h:874
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
unsigned long DWORD
Definition: ntddk_ex.h:95
SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY]
Definition: setypes.h:964
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
$ULONG GroupCount
Definition: setypes.h:960
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:624
#define HeapFree(x, y, z)
Definition: compat.h:403
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
BOOL WINAPI AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, PSID *pSid)
Definition: security.c:553
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by Applet(), DevInstallW(), CNetConnection::GetProperties(), NetIDPage_OnInitDialog(), and OnInitUserProfileDialog().

◆ IsValidComputerName()

static BOOL IsValidComputerName ( HWND  hDlg,
UINT  uId 
)
static

Definition at line 359 of file netid.c.

362 {
363  WCHAR szHostName[256];
364  DWORD dwError;
365 
366  GetWindowText(GetDlgItem(hDlg, uId), szHostName, ARRAYSIZE(szHostName));
367 
368  dwError = DnsValidateName_W(szHostName, DnsNameHostnameLabel);
369  if (dwError != ERROR_SUCCESS)
370  {
371  switch (dwError)
372  {
374  if (FormatMessageBox(hDlg, MB_YESNO | MB_ICONWARNING, 10, szHostName) == IDYES)
375  return TRUE;
376  break;
377 
378  case ERROR_INVALID_NAME:
379  FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 11);
380  return FALSE;
381 
383  FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 1029, szHostName);
384  break;
385 
387  FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 1030, szHostName);
388  break;
389  }
390 
391  return FALSE;
392  }
393 
394  return TRUE;
395 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDYES
Definition: winuser.h:829
#define DNS_ERROR_NON_RFC_NAME
Definition: winerror.h:1872
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
DNS_STATUS WINAPI DnsValidateName_W(PCWSTR name, DNS_NAME_FORMAT format)
Definition: names.c:124
#define MB_ICONWARNING
Definition: winuser.h:780
#define GetWindowText
Definition: winuser.h:5773
#define MB_YESNO
Definition: winuser.h:811
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MB_ICONERROR
Definition: winuser.h:781
#define MB_OK
Definition: winuser.h:784
#define DNS_ERROR_INVALID_NAME_CHAR
Definition: winerror.h:1877
#define ERROR_INVALID_NAME
Definition: compat.h:93
#define DNS_ERROR_NUMERIC_NAME
Definition: winerror.h:1878
static INT FormatMessageBox(HWND hDlg, UINT uType, DWORD dwMessage,...)
Definition: netid.c:49

Referenced by NetworkDlg_OnOK().

◆ IsValidDomainName()

static BOOL IsValidDomainName ( HWND  hDlg,
UINT  uId 
)
static

Definition at line 223 of file netid.c.

226 {
227  WCHAR szDomainName[256];
228  DWORD dwError;
229 
230  if (GetDlgItemTextW(hDlg, uId, szDomainName, ARRAYSIZE(szDomainName)) == 0)
231  return TRUE;
232 
233  dwError = DnsValidateName_W(szDomainName, DnsNameDomain);
234  if (dwError != ERROR_SUCCESS)
235  {
236  switch (dwError)
237  {
239  if (FormatMessageBox(hDlg, MB_YESNO | MB_ICONWARNING, 7, szDomainName) == IDYES)
240  return TRUE;
241  break;
242 
243  case ERROR_INVALID_NAME:
244  FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 8, szDomainName);
245  break;
246 
248  FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 1031, szDomainName);
249  break;
250 
252  FormatMessageBox(hDlg, MB_OK | MB_ICONERROR, 1032, szDomainName);
253  break;
254  }
255 
256  return FALSE;
257  }
258 
259  return TRUE;
260 }
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2271
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDYES
Definition: winuser.h:829
#define DNS_ERROR_NON_RFC_NAME
Definition: winerror.h:1872
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
DNS_STATUS WINAPI DnsValidateName_W(PCWSTR name, DNS_NAME_FORMAT format)
Definition: names.c:124
#define MB_ICONWARNING
Definition: winuser.h:780
#define MB_YESNO
Definition: winuser.h:811
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MB_ICONERROR
Definition: winuser.h:781
#define MB_OK
Definition: winuser.h:784
#define DNS_ERROR_INVALID_NAME_CHAR
Definition: winerror.h:1877
#define ERROR_INVALID_NAME
Definition: compat.h:93
#define DNS_ERROR_NUMERIC_NAME
Definition: winerror.h:1878
static INT FormatMessageBox(HWND hDlg, UINT uType, DWORD dwMessage,...)
Definition: netid.c:49

Referenced by DNSSuffixPropDlgProc().

◆ NetIDPage_OnApply()

static LONG NetIDPage_OnApply ( HWND  hwndDlg)
static

Definition at line 687 of file netid.c.

689 {
690  WCHAR ComputerDescription[MAX_COMPUTERDESCRIPTION_LENGTH + 1];
691  WCHAR NewComputerDescription[MAX_COMPUTERDESCRIPTION_LENGTH + 1];
692  HKEY KeyHandle = NULL;
693  DWORD dwSize;
694  LONG lError;
695 
697  L"SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Parameters",
698  0,
700  &KeyHandle);
701  if (lError != ERROR_SUCCESS)
702  return lError;
703 
704  GetDlgItemTextW(hwndDlg,
705  IDC_COMPDESC,
706  NewComputerDescription,
707  ARRAYSIZE(NewComputerDescription));
708  if (GetLastError() != ERROR_SUCCESS)
709  {
710  lError = GetLastError();
711  goto done;
712  }
713 
714  dwSize = sizeof(ComputerDescription);
715  lError = RegQueryValueExW(KeyHandle,
716  L"srvcomment",
717  0,
718  NULL,
719  (PBYTE)ComputerDescription,
720  &dwSize);
721  if (lError != ERROR_SUCCESS && lError != ERROR_FILE_NOT_FOUND)
722  goto done;
723 
724  lError = ERROR_SUCCESS;
725  if (wcscmp(ComputerDescription, NewComputerDescription) != 0)
726  {
727  lError = RegSetValueExW(KeyHandle,
728  L"srvcomment",
729  0,
730  REG_SZ,
731  (PBYTE)NewComputerDescription,
732  (wcslen(NewComputerDescription) + 1) * sizeof(WCHAR));
733  }
734 
735 done:
736  if (KeyHandle != NULL)
738 
739  return lError;
740 }
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2271
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define IDC_COMPDESC
Definition: resource.h:14
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define MAX_COMPUTERDESCRIPTION_LENGTH
Definition: netid.c:24
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
BYTE * PBYTE
Definition: pedump.c:66
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by NetIDPageProc().

◆ NetIDPage_OnInitDialog()

static VOID NetIDPage_OnInitDialog ( HWND  hwndDlg,
PNETIDDATA  pNetIdData 
)
static

Definition at line 634 of file netid.c.

637 {
638  WCHAR ComputerDescription[MAX_COMPUTERDESCRIPTION_LENGTH + 1];
639  DWORD RegSize = sizeof(ComputerDescription);
640  HKEY KeyHandle;
641  WCHAR szBuffer[512];
642  LONG lError;
643 
644  /* Display computer name and description */
646 
648  L"SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Parameters",
649  0,
651  &KeyHandle);
652  if (lError == ERROR_SUCCESS)
653  {
654  lError = RegQueryValueExW(KeyHandle,
655  L"srvcomment",
656  0,
657  NULL,
658  (LPBYTE)ComputerDescription,
659  &RegSize);
660  if (lError == ERROR_SUCCESS)
661  {
662  ComputerDescription[RegSize / sizeof(WCHAR)] = UNICODE_NULL;
663  SetDlgItemText(hwndDlg, IDC_COMPDESC, ComputerDescription);
664  }
665 
667  }
668 
669  /* Set the workgroup or domain name */
670  LoadStringW(hDllInstance, (pNetIdData->JoinStatus == NetSetupDomainName)? 6 : 5, szBuffer, ARRAYSIZE(szBuffer));
671  SetDlgItemText(hwndDlg, IDC_WORKGROUPDOMAIN, szBuffer);
672  SetDlgItemText(hwndDlg, IDC_WORKGROUPDOMAIN_NAME, pNetIdData->JoinName);
673 
674  /* Show the administrator note and disable controls when the user is not an administator */
675  if (!IsUserAdmin())
676  {
677  LoadStringW(hDllInstance, 1021, szBuffer, ARRAYSIZE(szBuffer));
678  SetDlgItemText(hwndDlg, IDC_MESSAGETEXT, szBuffer);
679 
682  }
683 }
#define IDC_NETWORK_PROPERTY
Definition: resource.h:19
#define ERROR_SUCCESS
Definition: deptool.c:10
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define IDC_MESSAGETEXT
Definition: resource.h:20
#define EM_SETLIMITTEXT
Definition: winuser.h:1993
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
NETSETUP_JOIN_STATUS JoinStatus
Definition: netid.c:37
#define SendDlgItemMessage
Definition: winuser.h:5817
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define IDC_WORKGROUPDOMAIN_NAME
Definition: resource.h:16
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define UNICODE_NULL
long LONG
Definition: pedump.c:60
#define IDC_COMPDESC
Definition: resource.h:14
static BOOL IsUserAdmin(VOID)
Definition: netid.c:163
smooth NULL
Definition: ftsmooth.c:416
#define IDC_WORKGROUPDOMAIN
Definition: resource.h:17
static HINSTANCE hDllInstance
Definition: netid.c:45
#define IDC_NETWORK_ID
Definition: resource.h:18
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetDlgItemText
Definition: winuser.h:5824
static const WCHAR L[]
Definition: oid.c:1250
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define MAX_COMPUTERDESCRIPTION_LENGTH
Definition: netid.c:24
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
LPWSTR JoinName
Definition: netid.c:36
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by NetIDPageProc().

◆ NetIDPageProc()

static INT_PTR CALLBACK NetIDPageProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 743 of file netid.c.

747 {
748  PNETIDDATA pNetIdData;
749 
750  pNetIdData = (PNETIDDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
751 
752  switch (uMsg)
753  {
754  case WM_INITDIALOG:
755  pNetIdData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(NETIDDATA));
756  if (pNetIdData != NULL)
757  {
758  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pNetIdData);
759  GetComputerNames(pNetIdData);
760  SetFullComputerName(hwndDlg, IDC_COMPUTERNAME, pNetIdData);
761  NetIDPage_OnInitDialog(hwndDlg, pNetIdData);
762  pNetIdData->bEnable = TRUE;
763  CheckForChangedNames(hwndDlg, pNetIdData);
764  }
765  return TRUE;
766 
767  case WM_NOTIFY:
768  switch (((LPNMHDR)lParam)->code)
769  {
770  case PSN_APPLY:
771  NetIDPage_OnApply(hwndDlg);
772  break;
773  }
774  break;
775 
776  case WM_COMMAND:
777  switch (LOWORD(wParam))
778  {
779  case IDC_COMPDESC:
780  if (HIWORD(wParam) == EN_CHANGE && pNetIdData->bEnable == TRUE)
781  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
782  break;
783 
787  hwndDlg,
789  (LPARAM)pNetIdData))
790  {
791  UpdateFullComputerName(hwndDlg, IDC_COMPUTERNAME, pNetIdData);
792  CheckForChangedNames(hwndDlg, pNetIdData);
793  }
794  break;
795  }
796  break;
797 
798  case WM_DESTROY:
799  if (pNetIdData != NULL)
800  {
801  if (pNetIdData->JoinName != NULL)
802  NetApiBufferFree(pNetIdData->JoinName);
803  HeapFree(GetProcessHeap(), 0, pNetIdData);
804  pNetIdData = NULL;
806  }
807  break;
808  }
809 
810  return FALSE;
811 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define TRUE
Definition: types.h:120
#define IDC_NETWORK_PROPERTY
Definition: resource.h:19
static LONG NetIDPage_OnApply(HWND hwndDlg)
Definition: netid.c:687
#define PSN_APPLY
Definition: prsht.h:117
static VOID UpdateFullComputerName(HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
Definition: netid.c:412
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
BOOL bEnable
Definition: netid.c:41
#define IDC_COMPDESC
Definition: resource.h:14
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
static HINSTANCE hDllInstance
Definition: netid.c:45
#define WM_DESTROY
Definition: winuser.h:1591
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
static VOID NetIDPage_OnInitDialog(HWND hwndDlg, PNETIDDATA pNetIdData)
Definition: netid.c:634
#define IDD_PROPPAGECOMPNAMECHENGE
Definition: resource.h:10
#define DialogBoxParam
Definition: winuser.h:5739
#define IDC_COMPUTERNAME
Definition: resource.h:15
#define DWLP_USER
Definition: winuser.h:866
static VOID SetFullComputerName(HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
Definition: netid.c:399
#define WM_COMMAND
Definition: winuser.h:1722
static VOID CheckForChangedNames(_In_ HWND hwndDlg, _In_ PNETIDDATA pNetIdData)
Definition: netid.c:446
static INT_PTR CALLBACK NetworkPropDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: netid.c:566
HWND WINAPI GetParent(_In_ HWND)
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
struct _NETIDDATA * PNETIDDATA
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static BOOL GetComputerNames(PNETIDDATA pNetIdData)
Definition: netid.c:77
#define HIWORD(l)
Definition: typedefs.h:246
#define GetWindowLongPtr
Definition: treelist.c:73
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
LPWSTR JoinName
Definition: netid.c:36
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:403
#define WM_NOTIFY
Definition: richedit.h:61
#define EN_CHANGE
Definition: winuser.h:2004

Referenced by CreateNetIDPropertyPage().

◆ NetworkDlg_OnInitDialog()

static VOID NetworkDlg_OnInitDialog ( HWND  hDlg,
PNETIDDATA  pNetIdData 
)
static

Definition at line 464 of file netid.c.

467 {
468  WCHAR MsgText[MAX_PATH * 2];
469 
470  if (LoadStringW(hDllInstance, 25, MsgText, ARRAYSIZE(MsgText)))
471  SetDlgItemText(hDlg, 1017, MsgText);
472 
474  SetDlgItemText(hDlg, 1002, pNetIdData->szHostName);
475  SetFullComputerName(hDlg, 1001, pNetIdData);
476 
477  /* Display the workgroup or domain name */
478  switch (pNetIdData->JoinStatus)
479  {
480  case NetSetupDomainName:
481  SetDlgItemText(hDlg, 116, pNetIdData->JoinName);
482  SetRadioBtnState(hDlg, TRUE);
483  break;
484 
486  SetDlgItemText(hDlg, 1007, pNetIdData->JoinName);
487  SetRadioBtnState(hDlg, FALSE);
488  break;
489 
490  default:
491  break;
492  }
493 }
#define TRUE
Definition: types.h:120
#define EM_SETLIMITTEXT
Definition: winuser.h:1993
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
NETSETUP_JOIN_STATUS JoinStatus
Definition: netid.c:37
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
static HINSTANCE hDllInstance
Definition: netid.c:45
#define MAX_HOSTNAME_LENGTH
Definition: netid.c:25
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR szHostName[MAX_HOSTNAME_LENGTH+1]
Definition: netid.c:30
#define MAX_PATH
Definition: compat.h:26
#define SetDlgItemText
Definition: winuser.h:5824
static VOID SetFullComputerName(HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
Definition: netid.c:399
static VOID SetRadioBtnState(HWND hDlg, BOOL IsDomain)
Definition: netid.c:338
#define SendMessage
Definition: winuser.h:5818
LPWSTR JoinName
Definition: netid.c:36

Referenced by NetworkPropDlgProc().

◆ NetworkDlg_OnOK()

static BOOL NetworkDlg_OnOK ( HWND  hDlg,
PNETIDDATA  pNetIdData 
)
static

Definition at line 497 of file netid.c.

500 {
501  WCHAR szMsgText[MAX_PATH], szMsgTitle[MAX_PATH];
502  HKEY KeyHandle;
503  DWORD dwError;
504 
505  if (pNetIdData->bHostNameChanged)
506  {
507  if (!IsValidComputerName(hDlg, 1002))
508  {
509  SetFocus(GetDlgItem(hDlg, 1002));
510  return FALSE;
511  }
512 
513  GetWindowText(GetDlgItem(hDlg, 1002), pNetIdData->szHostName, ARRAYSIZE(pNetIdData->szHostName));
514 
515  if (!SetComputerNameExW(ComputerNamePhysicalDnsHostname, pNetIdData->szHostName))
516  {
517  LoadStringW(hDllInstance, 4001, szMsgText, ARRAYSIZE(szMsgText));
518  MessageBoxW(hDlg, szMsgText, NULL, MB_OK | MB_ICONERROR);
519  return FALSE;
520  }
521 
522  pNetIdData->bHostNameChanged = FALSE;
523  }
524 
525  if (pNetIdData->bDomainNameChanged)
526  {
527  if (!SetComputerNameExW(ComputerNamePhysicalDnsDomain, pNetIdData->szDomainName))
528  {
529  /* FIXME: Show error message */
530  return FALSE;
531  }
532 
533  pNetIdData->bDomainNameChanged = FALSE;
534  }
535 
536  if (pNetIdData->bSyncDomainWithMembershipChanged)
537  {
539  L"SYSTEM\\CurrentControlSet\\Services\\TcpIp\\Parameters",
540  0,
542  &KeyHandle);
543  if (dwError == ERROR_SUCCESS)
544  {
546  L"SyncDomainWithMembership",
547  0,
548  REG_DWORD,
549  (LPBYTE)&pNetIdData->bSyncDomainWithMembership,
550  sizeof(pNetIdData->bSyncDomainWithMembership));
552  }
553 
555  }
556 
557  LoadStringW(hDllInstance, 4000, szMsgTitle, ARRAYSIZE(szMsgTitle));
558  LoadStringW(hDllInstance, 24, szMsgText, ARRAYSIZE(szMsgText));
559  MessageBoxW(hDlg, szMsgText, szMsgTitle, MB_OK | MB_ICONINFORMATION);
560 
561  return TRUE;
562 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL bSyncDomainWithMembershipChanged
Definition: netid.c:40
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define GetWindowText
Definition: winuser.h:5773
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
BOOL bDomainNameChanged
Definition: netid.c:39
smooth NULL
Definition: ftsmooth.c:416
static HINSTANCE hDllInstance
Definition: netid.c:45
BOOL bHostNameChanged
Definition: netid.c:38
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR szHostName[MAX_HOSTNAME_LENGTH+1]
Definition: netid.c:30
static BOOL IsValidComputerName(HWND hDlg, UINT uId)
Definition: netid.c:359
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MB_ICONINFORMATION
Definition: winuser.h:796
static const WCHAR L[]
Definition: oid.c:1250
#define MB_ICONERROR
Definition: winuser.h:781
#define MB_OK
Definition: winuser.h:784
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
BOOL bSyncDomainWithMembership
Definition: netid.c:35
#define REG_DWORD
Definition: sdbapi.c:596
BOOL WINAPI SetComputerNameExW(COMPUTER_NAME_FORMAT NameType, LPCWSTR lpBuffer)
Definition: compname.c:602
WCHAR szDomainName[MAX_DOMAINNAME_LENGTH+1]
Definition: netid.c:32
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by NetworkPropDlgProc().

◆ NetworkPropDlgProc()

static INT_PTR CALLBACK NetworkPropDlgProc ( HWND  hDlg,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 566 of file netid.c.

567 {
568  PNETIDDATA pNetIdData;
569 
570  pNetIdData = (PNETIDDATA)GetWindowLongPtr(hDlg, DWLP_USER);
571 
572  switch (Msg)
573  {
574  case WM_INITDIALOG:
575  pNetIdData = (PNETIDDATA)lParam;
576  if (pNetIdData != NULL)
577  {
578  SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pNetIdData);
579  NetworkDlg_OnInitDialog(hDlg, pNetIdData);
581  }
582  return TRUE;
583 
584  case WM_COMMAND:
585  switch (LOWORD(wParam))
586  {
587  case 1002:
588  if (HIWORD(wParam) == EN_CHANGE)
589  {
590  UpdateFullComputerName(hDlg, 1001, pNetIdData);
591  UpdateNetbiosName(hDlg, 1001, pNetIdData);
592  pNetIdData->bHostNameChanged = TRUE;
593  EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
594  }
595  break;
596 
597  case 1008: /* Domain radio button */
598  case 1004: /* Workgroup radio button */
599  if (SendDlgItemMessage(hDlg, 1008, BM_GETCHECK, 0, 0) == BST_CHECKED)
600  SetRadioBtnState(hDlg, TRUE);
601  else
602  SetRadioBtnState(hDlg, FALSE);
603  break;
604 
605  case 1003:
608  hDlg,
610  (LPARAM)pNetIdData))
611  {
612  UpdateFullComputerName(hDlg, 1001, pNetIdData);
613  EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
614  }
615  break;
616 
617  case IDOK:
618  if (NetworkDlg_OnOK(hDlg, pNetIdData))
619  EndDialog(hDlg, TRUE);
620  break;
621 
622  case IDCANCEL:
623  EndDialog(hDlg, FALSE);
624  break;
625  }
626  break;
627  }
628 
629  return FALSE;
630 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
static VOID NetworkDlg_OnInitDialog(HWND hDlg, PNETIDDATA pNetIdData)
Definition: netid.c:464
struct @1604 Msg[]
#define SendDlgItemMessage
Definition: winuser.h:5817
static VOID UpdateFullComputerName(HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
Definition: netid.c:412
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
static INT_PTR CALLBACK DNSSuffixPropDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: netid.c:264
#define BM_GETCHECK
Definition: winuser.h:1900
static HINSTANCE hDllInstance
Definition: netid.c:45
BOOL bHostNameChanged
Definition: netid.c:38
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define DialogBoxParam
Definition: winuser.h:5739
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1722
static VOID SetRadioBtnState(HWND hDlg, BOOL IsDomain)
Definition: netid.c:338
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
static BOOL NetworkDlg_OnOK(HWND hDlg, PNETIDDATA pNetIdData)
Definition: netid.c:497
struct _NETIDDATA * PNETIDDATA
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define BST_CHECKED
Definition: winuser.h:197
#define IDD_PROPPAGEDNSANDNETBIOS
Definition: resource.h:11
#define HIWORD(l)
Definition: typedefs.h:246
#define GetWindowLongPtr
Definition: treelist.c:73
static VOID UpdateNetbiosName(HWND hDlg, UINT uId, PNETIDDATA pNetIdData)
Definition: netid.c:428
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define EN_CHANGE
Definition: winuser.h:2004

Referenced by NetIDPageProc().

◆ SetFullComputerName()

static VOID SetFullComputerName ( HWND  hDlg,
UINT  uId,
PNETIDDATA  pNetIdData 
)
static

Definition at line 399 of file netid.c.

403 {
404  WCHAR szFullComputerName[512];
405 
406  wsprintf(szFullComputerName, L"%s.%s", pNetIdData->szHostName, pNetIdData->szDomainName);
407  SetDlgItemText(hDlg, uId, szFullComputerName);
408 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR szHostName[MAX_HOSTNAME_LENGTH+1]
Definition: netid.c:30
#define SetDlgItemText
Definition: winuser.h:5824
static const WCHAR L[]
Definition: oid.c:1250
#define wsprintf
Definition: winuser.h:5840
WCHAR szDomainName[MAX_DOMAINNAME_LENGTH+1]
Definition: netid.c:32

Referenced by NetIDPageProc(), and NetworkDlg_OnInitDialog().

◆ SetRadioBtnState()

static VOID SetRadioBtnState ( HWND  hDlg,
BOOL  IsDomain 
)
static

Definition at line 338 of file netid.c.

339 {
340  SendDlgItemMessage(hDlg, 1008, BM_SETCHECK, (WPARAM)IsDomain, 0);
341  SendDlgItemMessage(hDlg, 1004, BM_SETCHECK, (WPARAM)!IsDomain, 0);
342  EnableWindow(GetDlgItem(hDlg, 116), IsDomain);
343  EnableWindow(GetDlgItem(hDlg, 1007), !IsDomain);
344 }
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5817
#define BM_SETCHECK
Definition: winuser.h:1903
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)

Referenced by NetworkDlg_OnInitDialog(), and NetworkPropDlgProc().

◆ UpdateFullComputerName()

static VOID UpdateFullComputerName ( HWND  hDlg,
UINT  uId,
PNETIDDATA  pNetIdData 
)
static

Definition at line 412 of file netid.c.

416 {
417  WCHAR szFullComputerName[512];
418  WCHAR szHostName[256];
419 
420  GetWindowText(GetDlgItem(hDlg, 1002), szHostName, ARRAYSIZE(szHostName));
421 
422  wsprintf(szFullComputerName, L"%s.%s", szHostName, pNetIdData->szDomainName);
423  SetDlgItemText(hDlg, uId, szFullComputerName);
424 }
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define GetWindowText
Definition: winuser.h:5773
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetDlgItemText
Definition: winuser.h:5824
static const WCHAR L[]
Definition: oid.c:1250
#define wsprintf
Definition: winuser.h:5840
WCHAR szDomainName[MAX_DOMAINNAME_LENGTH+1]
Definition: netid.c:32

Referenced by NetIDPageProc(), and NetworkPropDlgProc().

◆ UpdateNetbiosName()

static VOID UpdateNetbiosName ( HWND  hDlg,
UINT  uId,
PNETIDDATA  pNetIdData 
)
static

Definition at line 428 of file netid.c.

432 {
433  WCHAR szHostName[256];
434  DWORD dwSize;
435 
436  GetWindowText(GetDlgItem(hDlg, 1002), szHostName, ARRAYSIZE(szHostName));
437 
438  dwSize = ARRAYSIZE(pNetIdData->szComputerName);
439  DnsHostnameToComputerNameW(szHostName,
440  pNetIdData->szComputerName,
441  &dwSize);
442 }
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH+1]
Definition: netid.c:34
#define GetWindowText
Definition: winuser.h:5773
BOOL WINAPI DnsHostnameToComputerNameW(LPCWSTR hostname, LPWSTR computername, LPDWORD size)
Definition: compname.c:686
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by NetworkPropDlgProc().

Variable Documentation

◆ hDllInstance