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.

82 lines
2.4 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // File: fail.cxx
  4. //
  5. // Contents: An exe that just returns: to test failure of process start.
  6. //
  7. // History: 1-Dec-94 BillMo Created.
  8. //
  9. //---------------------------------------------------------------------
  10. #include <windows.h>
  11. #include <tchar.h>
  12. #define FILE_SHARE_DELETE 0x00000004
  13. //+-------------------------------------------------------------------
  14. //
  15. // Function: WinMain
  16. //
  17. // Synopsis: Entry point to EXE - does little else
  18. //
  19. // Arguments:
  20. //
  21. // Returns: TRUE
  22. //
  23. // History: 1-Dec-94 BillMo Created
  24. //
  25. //--------------------------------------------------------------------
  26. int WINAPI WinMain(
  27. HINSTANCE hInstance,
  28. HINSTANCE hPrevInstance,
  29. char *lpszCmdLine,
  30. int nCmdShow)
  31. {
  32. //
  33. // We indicate that we ran by touching a file that olebind will look at the
  34. // timestamps of. This is because we don't have a unique error code
  35. // to distinguish errors during start of a server.
  36. //
  37. HANDLE hTouchFile;
  38. TCHAR tszFileName[MAX_PATH+1];
  39. DWORD dw;
  40. SYSTEMTIME st;
  41. FILETIME ft;
  42. GetSystemDirectory(tszFileName, MAX_PATH+1);
  43. _tcscat(tszFileName, TEXT("\\failtst.tst"));
  44. hTouchFile = CreateFile(tszFileName,
  45. GENERIC_READ|GENERIC_WRITE,
  46. FILE_SHARE_READ|FILE_SHARE_WRITE,
  47. NULL,
  48. OPEN_EXISTING,
  49. FILE_ATTRIBUTE_NORMAL,
  50. NULL);
  51. if (hTouchFile == INVALID_HANDLE_VALUE)
  52. {
  53. if (GetLastError() == ERROR_FILE_NOT_FOUND)
  54. {
  55. MessageBox(GetDesktopWindow(),
  56. TEXT("This program (fail.exe) must be run from olebind.exe"),
  57. TEXT("Error in test"),
  58. MB_OK);
  59. }
  60. else
  61. {
  62. MessageBox(GetDesktopWindow(),
  63. TEXT("This program (fail.exe) failed for unknown reason"),
  64. TEXT("Error in test"),
  65. MB_OK);
  66. GetLastError();
  67. }
  68. return 0;
  69. }
  70. GetSystemTime(&st);
  71. WriteFile(hTouchFile, &st, sizeof(st), &dw, NULL);
  72. CloseHandle(hTouchFile);
  73. return (0);
  74. }