* Generate random computer name (REACTOS-xxxxxxx) in Setup. Patch by David Quintana <gigaherz at gmail dot com> modified by me
See issue #6099 for more details.
svn path=/trunk/; revision=51358
+/* lpBuffer will be filled with a 15-char string (plus the null terminator) */
+static void
+GenerateComputerName(LPWSTR lpBuffer)
+{
+ static const WCHAR Chars[] = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ static const unsigned cChars = sizeof(Chars) / sizeof(WCHAR) - 1;
+ unsigned i;
+
+ wcscpy(lpBuffer, L"REACTOS-");
+
+ srand(GetTickCount());
+
+ /* fill in 7 characters */
+ for (i = 8; i < 15; i++)
+ lpBuffer[i] = Chars[rand() % cChars];
+
+ lpBuffer[15] = UNICODE_NULL; /* NULL-terminate */
+}
+
static INT_PTR CALLBACK
ComputerPageDlgProc(HWND hwndDlg,
UINT uMsg,
static INT_PTR CALLBACK
ComputerPageDlgProc(HWND hwndDlg,
UINT uMsg,
PWCHAR Password;
WCHAR Title[64];
WCHAR EmptyComputerName[256], NotMatchPassword[256], WrongPassword[256];
PWCHAR Password;
WCHAR Title[64];
WCHAR EmptyComputerName[256], NotMatchPassword[256], WrongPassword[256];
LPNMHDR lpnm;
if (0 == LoadStringW(hDllInstance, IDS_REACTOS_SETUP, Title, sizeof(Title) / sizeof(Title[0])))
LPNMHDR lpnm;
if (0 == LoadStringW(hDllInstance, IDS_REACTOS_SETUP, Title, sizeof(Title) / sizeof(Title[0])))
- /* Retrieve current computer name */
- Length = MAX_COMPUTERNAME_LENGTH + 1;
- GetComputerNameW(ComputerName, &Length);
+ /* Generate a new pseudo-random computer name */
+ GenerateComputerName(ComputerName);
/* Display current computer name */
SetDlgItemTextW(hwndDlg, IDC_COMPUTERNAME, ComputerName);
/* Display current computer name */
SetDlgItemTextW(hwndDlg, IDC_COMPUTERNAME, ComputerName);