2013-12-08 2 views
0

Как я могу запустить ex .NET exe из ресурсов? Я хочу выполнить встроенный ресурс exe в Process, но я не знаю, как и если это возможно. Я попытался с отражением, прежде чем заметил, что он работает только с управляемыми ресурсами, поэтому можно запустить неуправляемый ресурс, не извлекая его? Я буду признателен за любую информацию, связанную с этим. Спасибо заранее.Запуск неуправляемого ресурса

ответ

0

использование http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start(v=vs.110).aspx

внедренный ресурс должен быть скопирован в папку theoutput и использовали используя относительный путь

using System; 
using System.Diagnostics; 
using System.ComponentModel; 

namespace MyProcessSample 
{ 
    class MyProcess 
    { 
     // Opens the Internet Explorer application. 
     void OpenApplication(string myFavoritesPath) 
     { 
      // Start Internet Explorer. Defaults to the home page. 
      Process.Start("IExplore.exe"); 

      // Display the contents of the favorites folder in the browser. 
      Process.Start(myFavoritesPath); 
     } 

     // Opens urls and .html documents using Internet Explorer. 
     void OpenWithArguments() 
     { 
      // url's are not considered documents. They can only be opened 
      // by passing them as arguments. 
      Process.Start("IExplore.exe", "www.northwindtraders.com"); 

      // Start a Web page using a browser associated with .html and .asp files. 
      Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm"); 
      Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp"); 
     } 

     // Uses the ProcessStartInfo class to start new processes, 
     // both in a minimized mode. 
     void OpenWithStartInfo() 
     { 
      ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe"); 
      startInfo.WindowStyle = ProcessWindowStyle.Minimized; 

      Process.Start(startInfo); 

      startInfo.Arguments = "www.northwindtraders.com"; 

      Process.Start(startInfo); 
     } 

     static void Main() 
     { 
      // Get the path that stores favorite links. 
      string myFavoritesPath = 
       Environment.GetFolderPath(Environment.SpecialFolder.Favorites); 

      MyProcess myProcess = new MyProcess(); 

      myProcess.OpenApplication(myFavoritesPath); 
      myProcess.OpenWithArguments(); 
      myProcess.OpenWithStartInfo(); 
     } 
    } 
} 
Смежные вопросы