Guest

Untitled

By: a guest on Nov 26th, 2010  |  syntax: C++  |  size: 1.40 KB  |  hits: 416  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. // Phoenix.cpp
  2. // used to direct all shortcuts and existing bat files to the new
  3. // phoenixviewer.exe
  4. /* This program is free software. It comes without any warranty, to
  5. * the extent permitted by applicable law. You can redistribute it
  6. * and/or modify it under the terms of the Do What The Fuck You Want
  7. * To Public License, Version 2, as published by Sam Hocevar. See
  8. * http://sam.zoy.org/wtfpl/COPYING for more details. */
  9.  
  10.  
  11. #include "stdafx.h"
  12. #include <windows.h>
  13. #include <string>
  14. #include <iostream>
  15.  
  16.  
  17. int _tmain(int argc, wchar_t* argv[])
  18. {
  19.         std::wstring Parameters=L" ";
  20.  
  21.         for(int i = 0; i < argc; i++)
  22.         {
  23.                 std::wcout << "argv[" << i << "] = " << argv[i] << std::endl;
  24.                 if(i==0)Parameters.append(L" ");
  25.                 else Parameters.append(argv[i]);
  26.                
  27.         }
  28.        
  29.         PROCESS_INFORMATION processInformation;
  30.         STARTUPINFO startupInfo;
  31.         memset(&processInformation, 0, sizeof(processInformation));
  32.         memset(&startupInfo, 0, sizeof(startupInfo));
  33.         startupInfo.cb = sizeof(startupInfo);
  34.  
  35.         BOOL result=FALSE;
  36.         const wchar_t* pchrTemp = Parameters.c_str();
  37.         wchar_t * pwszParam = new wchar_t[Parameters.size() + 1];
  38.  
  39.         wcscpy_s(pwszParam, Parameters.size() + 1, pchrTemp);
  40.         std::wcout << "DONE is " << Parameters.c_str() << std::endl;
  41.  
  42.         result = ::CreateProcess(L"PhoenixViewer.exe",pwszParam, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &startupInfo, &processInformation);
  43.  
  44.         return result;
  45. }