InitiateSystemShutdown怎么用呀
谁能帮帮我呀  急呀

解决方案 »

  1.   

    在.net里面调用?需要通过P/Invoke,下面是个封装的例子,你可以直接调用InitiateSystemShutdownApublic partial class NativeMethods {
        
        /// Return Type: BOOL->int
        ///lpMachineName: LPSTR->CHAR*
        ///lpMessage: LPSTR->CHAR*
        ///dwTimeout: DWORD->unsigned int
        ///bForceAppsClosed: BOOL->int
        ///bRebootAfterShutdown: BOOL->int
        [System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint="InitiateSystemShutdownA")]
        [return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
    public static extern  bool InitiateSystemShutdownA([System.Runtime.InteropServices.InAttribute()] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)] string lpMachineName, [System.Runtime.InteropServices.InAttribute()] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)] string lpMessage, uint dwTimeout, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] bool bForceAppsClosed, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] bool bRebootAfterShutdown) ;}