2016-06-24 17 views
0

Ich verwende den folgenden Code, um IIS in Windows Form zu starten.versucht, iis in Windows-Formular zu öffnen

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()); 

Aber ich bin immer Fehler:

the system cannot find the file

Aber das Gleiche funktioniert für Notizblock.

+0

Nun, ist '" C: \ Windows \ System32 \ inetsrv \ inetmgr "' tatsächlich vorhanden? – bkribbs

+0

Ja. Es existiert tatsächlich. – user1104946

+0

Ist es möglich, dass das Programm keine Berechtigungen hat? – bkribbs

Antwort

2

hatte ich das gleiche Problem und der einzige Weg, ich war gefunden:

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

Ich hoffe, es hilft!