[DllImport("user32.dll", SetLastError=true)]
static extern bool ShutdownBlockReasonCreate(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] string reason);
Declare Function ShutdownBlockReasonCreate Lib "user32.dll" (ByVal hWnd As IntPtr, <Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.LPWStr)> ByVal reason As String) As Boolean
None.
Do you know one? Please contribute it!
hWnd - A handle to the main window of the application.
reason - The reason the application must block system shutdown.
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));
}