2009-07-28 7 views
1

Process.StartProcessStartInfoを使用してCD(または他のメディア)の自動実行をエミュレートする最も近い方法は何ですか?Process.StartからCDを自動再生する

私はのような明白なものを試してみた:私は明らかに関与して実行ファイルを動作するようにautorun.infファイルを解析することができます

// Just opens the folder 
Process.Start("F:"); 

// Ditto 
Process.Start(new ProcessStartInfo("F:") {UseShellExecute = true}); 

// Throws System.ComponentModel.Win32Exception: No application is associated with the specified file for this operation 
Process.Start(new ProcessStartInfo("F:") {UseShellExecute = true, Verb = "autorun"}); 

が、それを行うための簡単な方法があります場合、私はちょうど思ったんだけど。

答えて

0

Process.Start(@"F:\autorun.inf"); 

EDIT [ファイルが存在するかどうかを確認]:申し訳ありませんが、自動実行がエクスプローラの機能のようですが。自分でファイルを解析する必要があります。

Const DVD_DRIVE As String = "E:\" 

If IO.File.Exists(DVD_DRIVE & "autorun.inf") Then 
    Dim textreader As New IO.StreamReader(DVD_DRIVE & "autorun.inf") 
    Dim sLine As String = "" 

    sLine = textreader.ReadLine() 
    Do While Not String.IsNullOrEmpty(sLine) 
     If sLine.StartsWith("open=") Then 
      Dim applicationstring As String 
      Dim autorunapp As New Process() 
      Dim startinfo As ProcessStartInfo 

      applicationstring = sLine.Substring(5) 

      startinfo = New ProcessStartInfo(DVD_DRIVE & applicationstring) 

      startinfo.WorkingDirectory = DVD_DRIVE 
      autorunapp.StartInfo = startinfo 
      autorunapp.Start() 

      Exit Do 
     End If 

     sLine = textreader.ReadLine() 
    Loop 

    textreader.Close() 
End If 
+0

私は、ファイルの内容をメモ帳に開くだけです。 – Thom

関連する問題