Leaked source code of windows server 2003
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.

74 lines
1.9 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. //---------------------------------------------------------------------------
  4. #include "regedt32.h"
  5. // stolen from the CRT, used to shrink our code
  6. int _stdcall ModuleEntry(void)
  7. {
  8. STARTUPINFO si;
  9. LPSTR pszCmdLine = GetCommandLine();
  10. if ( *pszCmdLine == '\"' ) {
  11. /*
  12. * Scan, and skip over, subsequent characters until
  13. * another double-quote or a null is encountered.
  14. */
  15. while ( *++pszCmdLine && (*pszCmdLine
  16. != '\"') );
  17. /*
  18. * If we stopped on a double-quote (usual case), skip
  19. * over it.
  20. */
  21. if ( *pszCmdLine == '\"' )
  22. pszCmdLine++;
  23. }
  24. else {
  25. while (*pszCmdLine > ' ')
  26. pszCmdLine++;
  27. }
  28. /*
  29. * Skip past any white space preceeding the second token.
  30. */
  31. while (*pszCmdLine && (*pszCmdLine <= ' ')) {
  32. pszCmdLine++;
  33. }
  34. si.dwFlags = 0;
  35. GetStartupInfoA(&si);
  36. return WinMain(GetModuleHandle(NULL), NULL, pszCmdLine,
  37. si.dwFlags & STARTF_USESHOWWINDOW ? si.wShowWindow : SW_SHOWDEFAULT);
  38. }
  39. const char szFile[] = "regedit.exe";
  40. //---------------------------------------------------------------------------
  41. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  42. {
  43. TCHAR szFullPath[MAX_PATH+1];
  44. *szFullPath = 0;
  45. if (GetWindowsDirectory(szFullPath, ARRAYSIZE(szFullPath)))
  46. {
  47. if (!PathAppend(szFullPath, szFile))
  48. {
  49. *szFullPath = 0;
  50. }
  51. szFullPath[MAX_PATH] = 0; // Ensure NULL termination
  52. }
  53. if (!*szFullPath)
  54. {
  55. StringCchCopy(szFullPath, ARRAYSIZE(szFullPath), szFile);
  56. }
  57. ShellExecute(HWND_DESKTOP, NULL, szFullPath, lpCmdLine, NULL, nCmdShow);
  58. ExitProcess(0);
  59. return 0;
  60. }