This code sample from the shell32.dll source code shows how the Windows XP product key is retrieved in C++ code.
329 330 331 332 333 334 335 336 337 338 339 340 | else if (err == ERROR_FILE_NOT_FOUND) { /* * OEM ID didn't exist, so look for the Product ID */ ShowWindow (GetDlgItem(hDlg, IDD_OEMID), SW_HIDE); err = RegGetStringAndRealloc(hkey, c_szAboutProductID, &lpszValue, &cb); if (!err) { SetDlgItemText(hDlg, IDD_SERIALNUM, lpszValue); } } |
The source code below will draw a product banner and a blue strip, this is branding for all Windows XP components.
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | BOOL_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) { BOOL_PTR bReturn = TRUE; switch (wMsg) { case WM_INITDIALOG: _InitAboutDlg(hDlg, (LPABOUT_PARAMS)lParam); break; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hDlg, &ps); // We draw the product banner and a blue strip. In order to support high DPI monitors // and scaled fonts we must scale the image and the strip to the proportions of the dialog. // // +-----------------------------+ // | Product Banner (413x72) | // | | // +-----------------------------+ // | Blue Strip (413x5) | // +-----------------------------+ HDC hdcMem = CreateCompatibleDC(hdc); int cxDlg; { RECT rc; GetClientRect(hDlg, &rc); cxDlg = rc.right; } if (hdcMem) { BOOL fDeep = (SHGetCurColorRes() > 8); HBITMAP hbmBand, hbmAbout; int cxDest = MulDiv(413,cxDlg,413); int cyDest = MulDiv(72,cxDlg,413); UINT uID; UINT uXpSpLevel = 0; HMODULE hResourceDll = HINST_THISDLL; if (IsOS(OS_PERSONAL)) { uID = (fDeep ? IDB_ABOUTPERSONAL256 : IDB_ABOUTPERSONAL16); } #ifndef _WIN64 else if (IsOS(OS_EMBEDDED)) { uID = (fDeep ? IDB_ABOUTEMBEDDED256 : IDB_ABOUTEMBEDDED16); } else if (IsOS(OS_TABLETPC)) { uXpSpLevel = 1; uID = (fDeep ? IDB_ABOUTTABLETPC256_SHELL32_DLL : IDB_ABOUTTABLETPC16_SHELL32_DLL); } else if (IsOS(OS_MEDIACENTER)) { uXpSpLevel = 1; uID = (fDeep ? IDB_ABOUTMEDIACENTER256_SHELL32_DLL : IDB_ABOUTMEDIACENTER16_SHELL32_DLL); } #endif // !_WIN64 else { uID = (fDeep ? IDB_ABOUT256 : IDB_ABOUT16); } // If this bitmap was added for a Windows XP service pack, // and lives in a special resource DLL, attempt to load it // now. If this fails, revert to the Professional bitmaps. if (uXpSpLevel > 0) { hResourceDll = LoadLibraryEx(TEXT("winbrand.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE); if (hResourceDll == NULL) { hResourceDll = HINST_THISDLL; uID = (fDeep ? IDB_ABOUT256 : IDB_ABOUT16); } } // paint the bitmap for the windows product hbmAbout = LoadImage(hResourceDll, MAKEINTRESOURCE(uID), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS); if (hResourceDll != HINST_THISDLL) { FreeLibrary(hResourceDll); } if ( hbmAbout ) { HBITMAP hbmOld = SelectObject(hdcMem, hbmAbout); if (hbmOld) { StretchBlt(hdc, 0, 0, cxDest, cyDest, hdcMem, 0,0,413,72, SRCCOPY); SelectObject(hdcMem, hbmOld); } DeleteObject(hbmAbout); } // paint the blue band below it hbmBand = LoadImage(HINST_THISDLL, MAKEINTRESOURCE(fDeep ? IDB_ABOUTBAND256:IDB_ABOUTBAND16), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS); if ( hbmBand ) { HBITMAP hbmOld = SelectObject(hdcMem, hbmBand); if (hbmOld) { StretchBlt(hdc, 0, cyDest, cxDest, MulDiv(5,cxDlg,413), hdcMem, 0,0,413,5, SRCCOPY); SelectObject(hdcMem, hbmOld); } DeleteObject(hbmBand); } DeleteDC(hdcMem); } EndPaint(hDlg, &ps); break; } case WM_COMMAND: EndDialog(hDlg, TRUE); break; case WM_NOTIFY: if ((IDD_EULA == (int)wParam) && (NM_CLICK == ((LPNMHDR)lParam)->code)) { SHELLEXECUTEINFO sei = { 0 }; sei.cbSize = sizeof(SHELLEXECUTEINFO); sei.fMask = SEE_MASK_DOENVSUBST; sei.hwnd = hDlg; sei.nShow = SW_SHOWNORMAL; sei.lpFile = TEXT("%windir%\\system32\\eula.txt"); ShellExecuteEx(&sei); } else { // WM_NOTIFY not handled. bReturn = FALSE; } break; default: // Not handled. bReturn = FALSE; } return bReturn; } |
This code is not too complicated, but I am sure there are better ways to do this.
Another code sample shows a tooltip.
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | // -------------------------------------------------------------------------- // CTooltip::Show // // Arguments: <none> // // Returns: <none> // // Purpose: Shows the tooltip window. // // History: 2000-06-12 vtan created // -------------------------------------------------------------------------- void CTooltip::Show (void) const { TOOLINFO toolInfo; ZeroMemory(&toolInfo, sizeof(toolInfo)); toolInfo.cbSize = sizeof(toolInfo); toolInfo.uId = PtrToUint(_hwnd); (LRESULT)SendMessage(_hwnd, TTM_TRACKACTIVATE, TRUE, reinterpret_cast<LPARAM>(&toolInfo)); } |
There are a lot of cool icons in the shell32.dll file, here is an archive of the Windows XP shell32.dll contents with all source code.
https://www.securitronlinux.com/arma3/shell32.7z
Windows XP OS Loader source code.
This is part of the code that does the actual operating System Loading.