Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.5 KiB

  1. #include "windows.h"
  2. #include "windowsx.h"
  3. #include "stdio.h"
  4. #include "shlobj.h"
  5. #define VERSION TEXT("0.00")
  6. #define SIZEOF(x) sizeof(x)
  7. #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
  8. typedef HRESULT(*PFNNETACCESSWIZARD)(HWND,UINT,BOOL*);
  9. int UsageErr()
  10. {
  11. fprintf(stderr, TEXT("netplwizexe: [NAW_NETID|NAW_PSDOMAINJOINFAILED|NAW_PSDOMAINJOINED]\n"));
  12. return -1;
  13. }
  14. INT __cdecl main(INT cArgs, LPTSTR pArgs[])
  15. {
  16. UINT nid;
  17. HMODULE hLib;
  18. if (cArgs < 1)
  19. return UsageErr();
  20. if (!lstrcmp(pArgs[1], TEXT("NAW_NETID")))
  21. nid = NAW_NETID;
  22. else if (!lstrcmp(pArgs[1], TEXT("NAW_PSDOMAINJOINFAILED")))
  23. nid = NAW_PSDOMAINJOINFAILED;
  24. else if (!lstrcmp(pArgs[1], TEXT("NAW_PSDOMAINJOINED")))
  25. nid = NAW_PSDOMAINJOINED;
  26. else
  27. return UsageErr();
  28. hLib = LoadLibrary(TEXT("netplwiz.dll"));
  29. if (hLib)
  30. {
  31. PFNNETACCESSWIZARD pfnNetAccessWizard;
  32. pfnNetAccessWizard = (PFNNETACCESSWIZARD)GetProcAddress(hLib, TEXT("NetAccessWizard"));
  33. if (pfnNetAccessWizard)
  34. {
  35. HRESULT hr;
  36. BOOL fReboot;
  37. hr = pfnNetAccessWizard(NULL, nid, &fReboot);
  38. fprintf(stderr, TEXT("netplwizexe: hr=%X %s\n"), hr, fReboot?TEXT("REBOOT"):TEXT("NO reboot"));
  39. }
  40. else
  41. {
  42. fprintf(stderr, TEXT("netplwizexe: can not GetProcAddress(\"NetAccessWizard\")\n"));
  43. }
  44. }
  45. else
  46. {
  47. fprintf(stderr, TEXT("netplwizexe: can not LoadLibrary(\"netplwiz.dll\")\n"));
  48. }
  49. return 0;
  50. }