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.

62 lines
1.6 KiB

  1. #include <windows.h>
  2. #include <tchar.h>
  3. #include <stdio.h>
  4. int wmain(int argc, WCHAR *argv[])
  5. {
  6. HRESULT hr=S_FALSE;
  7. WCHAR szApplication[MAX_PATH];
  8. WCHAR szCommandLine[MAX_PATH];
  9. wcscpy(szApplication, L"");
  10. wcscpy(szCommandLine, L"");
  11. for (int i=0; i<argc; i++)
  12. {
  13. RETAILMSG(1, (_T("argv[%i]=%s \n"), i, argv[i]));
  14. }
  15. if (argc<2)
  16. {
  17. RETAILMSG(1, (_T("Usage: %s application dll,proc\n"), argv[0]));
  18. return 1;
  19. }
  20. wcscat(szApplication, argv[1]);
  21. for (i=2; i<argc; i++)
  22. {
  23. wcscat(szCommandLine, argv[i]);
  24. wcscat(szCommandLine, L" ");
  25. }
  26. STARTUPINFO si;
  27. memset(&si, 0, sizeof(si));
  28. si.cb = sizeof(si);
  29. PROCESS_INFORMATION pi;
  30. RETAILMSG(1, (_T("szApplication: %s\nszCommandLine: %s\n"), szApplication,szCommandLine));
  31. BOOL fProcessCreated = ::CreateProcess(
  32. szApplication,
  33. szCommandLine,
  34. NULL,
  35. NULL,
  36. FALSE,
  37. 0,
  38. NULL,
  39. NULL,
  40. &si,
  41. &pi);
  42. if (!fProcessCreated)
  43. {
  44. LONG res=::GetLastError();
  45. hr = HRESULT_FROM_WIN32(res);
  46. }
  47. RETAILMSG(1, (_T("File: %s Line :%d, hr=%08x\n"),_T(__FILE__),__LINE__, hr));
  48. return 0;
  49. }