Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3. using System.ComponentModel;
  4.  
  5. namespace MyProcessSample
  6. {
  7. /// <summary>
  8. /// Shell for the sample.
  9. /// </summary>
  10. public class MyProcess
  11. {
  12.  
  13. /// <summary>
  14. /// Opens the Internet Explorer application.
  15. /// </summary>
  16. public void OpenApplication(string myFavoritesPath)
  17. {
  18. // Start Internet Explorer. Defaults to the home page.
  19. Process.Start("IExplore.exe");
  20.  
  21. // Display the contents of the favorites folder in the browser.
  22. Process.Start(myFavoritesPath);
  23.  
  24. }
  25.  
  26. /// <summary>
  27. /// Opens urls and .html documents using Internet Explorer.
  28. /// </summary>
  29. public void OpenWithArguments()
  30. {
  31. // url's are not considered documents. They can only be opened
  32. // by passing them as arguments.
  33. Process.Start("IExplore.exe", "www.northwindtraders.com");
  34.  
  35. // Start a Web page using a browser associated with .html and .asp files.
  36. Process.Start("IExplore.exe", "C:\myPath\myFile.htm");
  37. Process.Start("IExplore.exe", "C:\myPath\myFile.asp");
  38. }
  39.  
  40. /// <summary>
  41. /// Uses the ProcessStartInfo class to start new processes, both in a minimized
  42. /// mode.
  43. /// </summary>
  44. public void OpenWithStartInfo()
  45. {
  46.  
  47. ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
  48. startInfo.WindowStyle = ProcessWindowStyle.Minimized;
  49.  
  50. Process.Start(startInfo);
  51.  
  52. startInfo.Arguments = "www.northwindtraders.com";
  53.  
  54. Process.Start(startInfo);
  55.  
  56. }
  57.  
  58. public static void Main()
  59. {
  60. // Get the path that stores favorite links.
  61. string myFavoritesPath =
  62. Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
  63.  
  64. MyProcess myProcess = new MyProcess();
  65.  
  66. myProcess.OpenApplication(myFavoritesPath);
  67. myProcess.OpenWithArguments();
  68. myProcess.OpenWithStartInfo();
  69.  
  70. }
  71. }
  72. }
  73.  
  74. System.Diagnostics.Process.Start("iexplore", "http://example.com");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement