Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than shlwapi, prefix the name with the module name and a period.
SHMessageBoxCheck (shlwapi)
.
C# Signature:
/* The SHMessageBoxCheck() function is a Windows Shell API function that displays a custom messagebox with a "never ask me again" check box. When the user checks the checkbox, the dialog never shows up again. The shell API .dll exports this function by ordinal only. The entrypoint is ordinal 185 for ASCII and 191 for unicode. */
[DllImport("shlwapi.dll", EntryPoint="#185", ExactSpelling=true, PreserveSig=false)]
public static extern int SHMessageBoxCheck(
[In] IntPtr hwnd,
[In] String pszText,
[In] String pszTitle,
[In] MessageBoxCheckFlags uType,
[In] int iDefault,
[In] string pszRegVal
);
VB Signature:
Declare Function SHMessageBoxCheck Lib "shlwapi.dll" (TODO) As TODO
User-Defined Types:
None.
Alternative Managed API:
Do you know one? Please contribute it!
Notes:
/* We use the Windows Shell function SHMessageBoxCheck, so we have to define this parallel enum of the definitions in winuser.h. */
The Windows Shell (Explorer) stores your preference in the following registry key:
HKEY_CURRENT_USER
Software
Microsoft
Windows
CurrentVersion
Explorer
DontShowMeThisDialogAgain
One problem: If you have an application that you must uninstall, how do you install this key for all users? For example, suppose users X and Y have checked the "Do not show me this dialog again" checkbox. Now user X uninstalls the program. The installer would need to be able to go into user Y's registry settings to remove the registry key, which may not be possible depending on system permissions. I don't know how to solve this problem.
Tips & Tricks:
Note the discussion on what to do when you have multiple dialog options, like YES/NO and OK/CANCEL.
Sample Code:
/* This code displays a dialog box with a "Don't show me this dialog again" checkbox and an OK button. In normal circumstances, result will always be 0 on return. */
int result;
try
{
result = SHMessageBoxCheck(
this.Handle,
"This text fills the dialog",
"This text is in the title bar",
MessageBoxCheckFlags.MB_OK | MessageBoxCheckFlags.MB_ICONINFORMATION,
0,
"MyApplicationName.exe" // This last argument is the value of the registry key
);
}
catch( Exception e )
{
// Note that the only exceptions we can get here are inter-op exceptions, I think.
result = -1;
}
if( result == -1 )
{
// The dialog didn't show up, so do some alternate action here.
}
Displays a message box with a "Never show this dialog again" check box. This dialog is useful for displaying a one-time message to the user where they are likely never to want to see the dialog again.
12/14/2007 3:29:55 PM - 199.0.156.111
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).