2016-06-24 7 views
0

WindowsフォームでIISを起動するために、以下のコードを使用しています。Windowsフォームでiisを開こうとしています

if (hWndDocked != IntPtr.Zero) //don't do anything if there's already a window docked. 
    return; 

hWndParent = IntPtr.Zero; 

pDocked = Process.Start(@"C:\Windows\System32\inetsrv\inetmgr"); 
while (hWndDocked == IntPtr.Zero) 
{ 
    pDocked.WaitForInputIdle(1000); //wait for the window to be ready for input; 
    pDocked.Refresh();    //update process info 
    if (pDocked.HasExited) 
    { 
     return; //abort if the process finished before we got a handle. 
    } 
    hWndDocked = pDocked.MainWindowHandle; //cache the window handle 
} 
//Windows API call to change the parent of the target window. 
//It returns the hWnd of the window's parent prior to this call. 
hWndOriginalParent = SetParent(hWndDocked, panel1.Handle); 

//Wire up the event to keep the window sized to match the control 
panel1.SizeChanged += new EventHandler(Panel1_Resize); 
//Perform an initial call to set the size. 
Panel1_Resize(new Object(), new EventArgs()); 

しかし、私はエラーになっています:

the system cannot find the file

しかし、同じことはメモ帳のために働きます。

+0

「C:\ Windows \ System32 \ inetsrv \ inetmgr」は実際に存在しますか? – bkribbs

+0

はい。それは実際に存在します。 – user1104946

+0

プログラムに権限がない可能性はありますか? – bkribbs

答えて

2

私は同じ問題を持っていたし、私が見つけた唯一の方法は、このでした:私はそれが役に立てば幸い

Process.Start(Environment.SystemDirectory + "\\inetsrv\\iis.msc"); 

関連する問題