@msdn=http://msdn2.microsoft.com/en-us/library/aa376877.aspx @pinvoke=http://pinvoke.net/$$$.htm Summary: Indicates that the system cannot be shut down and sets a reason string to be displayed to the user if system shutdown is initiated. !!!!C# Signature: [DllImport("user32.dll", SetLastError=true)] static extern bool ShutdownBlockReasonCreate(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] string reason); !!!!VB Signature: Declare Function ShutdownBlockReasonCreate Lib "user32.dll" (ByVal hWnd As IntPtr, <Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.LPWStr)> ByVal reason As String) As Boolean !!!!User-Defined Types: None. !!!!Alternative Managed API: Do you know one? Please contribute it! !!!!Parameters: hWnd - A handle to the main window of the application. reason - The reason the application must block system shutdown. !!!!Tips & Tricks: * Invisible windows won't show up in Vista's "Running Applications" dialog on shutdown/logoff and therefore the reason set with this method will not be visible to the end-user :-(. * Make sure you also block/delay the WM_QUERYENDSESSION message. !!!!Sample Code: IntPtr handleForShutdownBlocker = shutdownBlockingForm.Handle; if (!ShutdownBlockReasonCreate(handleForShutdownBlocker, UIMessages.GetString("ShutdownBlockReason"))) { // failed, log error code and handle used. int error = Marshal.GetLastWin32Error(); log.Error(string.Format("Failed calling ShutdownBlockReasonCreate. Error code: {0}, blocking form handle: {1}", error, handleForShutdownBlocker)); } Documentation: ShutdownBlockReasonCreate@msdn on MSDN
Edit user32.ShutdownBl...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.