<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://nsis.sourceforge.io/mediawiki/index.php?action=history&amp;feed=atom&amp;title=SHMessageBoxCheck</id>
	<title>SHMessageBoxCheck - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://nsis.sourceforge.io/mediawiki/index.php?action=history&amp;feed=atom&amp;title=SHMessageBoxCheck"/>
	<link rel="alternate" type="text/html" href="https://nsis.sourceforge.io/mediawiki/index.php?title=SHMessageBoxCheck&amp;action=history"/>
	<updated>2026-04-27T12:41:55Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>https://nsis.sourceforge.io/mediawiki/index.php?title=SHMessageBoxCheck&amp;diff=24837&amp;oldid=prev</id>
		<title>Ede 123: /* Example */ add an image</title>
		<link rel="alternate" type="text/html" href="https://nsis.sourceforge.io/mediawiki/index.php?title=SHMessageBoxCheck&amp;diff=24837&amp;oldid=prev"/>
		<updated>2016-10-13T01:39:58Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Example: &lt;/span&gt; add an image&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;â† Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 01:39, 13 October 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l42&quot;&gt;Line 42:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 42:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Example ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Example ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[File:SHMessageBoxCheck.png]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;highlight-nsis&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;highlight-nsis&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key n22049_wiki-wiki_:diff::1.12:old-24835:rev-24837 --&gt;
&lt;/table&gt;</summary>
		<author><name>Ede 123</name></author>
	</entry>
	<entry>
		<id>https://nsis.sourceforge.io/mediawiki/index.php?title=SHMessageBoxCheck&amp;diff=24835&amp;oldid=prev</id>
		<title>Ede 123: Created page with &quot;== Description ==  &#039;&#039;&#039;SHMessageBoxCheck&#039;&#039;&#039; basically works like MessageBox but includes a checkbox that gives the user the option not to show the mess...&quot;</title>
		<link rel="alternate" type="text/html" href="https://nsis.sourceforge.io/mediawiki/index.php?title=SHMessageBoxCheck&amp;diff=24835&amp;oldid=prev"/>
		<updated>2016-10-13T01:30:11Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Description ==  &amp;#039;&amp;#039;&amp;#039;SHMessageBoxCheck&amp;#039;&amp;#039;&amp;#039; basically works like &lt;a href=&quot;/Reference/MessageBox&quot; title=&quot;Reference/MessageBox&quot;&gt;MessageBox&lt;/a&gt; but includes a checkbox that gives the user the option not to show the mess...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Description ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;SHMessageBoxCheck&amp;#039;&amp;#039;&amp;#039; basically works like [[Reference/MessageBox|MessageBox]] but includes a checkbox that gives the user the option not to show the message box again.&lt;br /&gt;
&lt;br /&gt;
For example this can be used to give the user a simple &amp;#039;&amp;#039;Yes / No / Always Yes / Always No&amp;#039;&amp;#039; choice, e.g. when asking whether to remove files that weren&amp;#039;t part of the original installation or have been modified.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;SHMessageBoxCheck&amp;#039;&amp;#039;&amp;#039; is based on the [https://msdn.microsoft.com/library/windows/desktop/bb773836.aspx Windows API function of the same name] called via the [http://nsis.sourceforge.net/Docs/System/System.html NSIS System Plug-in].&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;highlight-nsis&amp;gt;&lt;br /&gt;
!include SHMessageBoxCheck.nsh&lt;br /&gt;
&lt;br /&gt;
${SHMessageBoxCheckInit} unique_string&lt;br /&gt;
${SHMessageBoxCheck} caption text type&lt;br /&gt;
${SHMessageBoxCheckCleanup}&lt;br /&gt;
&amp;lt;/highlight-nsis&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Initialization ===&lt;br /&gt;
&lt;br /&gt;
To initialize call &amp;lt;code&amp;gt;${SHMessageBoxCheckInit} unique_string&amp;lt;/code&amp;gt; to create a unique name by which to identify your message box. Microsoft recommends to use a GUID as &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;unique_string&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; but any reasonably distinct string will do.&lt;br /&gt;
&lt;br /&gt;
=== Showing a Message Box ===&lt;br /&gt;
&lt;br /&gt;
To show a message box call &amp;lt;code&amp;gt;${SHMessageBoxCheck} caption text type&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;caption&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;text&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; are simple strings specifying the caption of the window and the content text.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; is used to define which buttons are shown and whether to include an image in the message box. For possible choices refer to the [[#The Script|the script&amp;#039;s code below]]. To combine two options use the &amp;quot;or&amp;quot; operator, e.g. &amp;lt;code&amp;gt;${MB_YESNO}|${MB_ICONINFORMATION}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Return value&lt;br /&gt;
&lt;br /&gt;
The macro returns the user&amp;#039;s choice (i.e. the button he/she clicked in the dialog). If the user chooses not to see the dialog again the macro will always return the last choice without displaying a message box.&lt;br /&gt;
&lt;br /&gt;
The return value is stored as the first value on the stack, e.g. a &amp;lt;code&amp;gt;Pop $0&amp;lt;/code&amp;gt; will store the result in the &amp;lt;code&amp;gt;$0&amp;lt;/code&amp;gt; user variable.&lt;br /&gt;
&lt;br /&gt;
Return values are integers. For clarity there are defines (e.g. &amp;lt;code&amp;gt;${IDOK}&amp;lt;/code&amp;gt; for the OK button) which can be used in comparisons. Please refer to [[#The Script|the script&amp;#039;s code below]] for the full list of possible return values.&lt;br /&gt;
&lt;br /&gt;
=== Finalization ===&lt;br /&gt;
&lt;br /&gt;
After you&amp;#039;re done call &amp;lt;code&amp;gt;${SHMessageBoxCheckCleanup}&amp;lt;/code&amp;gt; which will reset the state of the message box (i.e. the users choice wether or not to see the message box again will be reset).&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;highlight-nsis&amp;gt;&lt;br /&gt;
!include macros\SHMessageBoxCheck.nsh&lt;br /&gt;
&lt;br /&gt;
!include FileFunc.nsh&lt;br /&gt;
!insertmacro Locate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Section Uninstall&lt;br /&gt;
    StrCpy $INSTDIR &amp;quot;C:\Your\Installation\Directory&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    # initialize SHMessageBoxCheck&lt;br /&gt;
    ${SHMessageBoxCheckInit} &amp;quot;unique_application_string&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    # locate leftover files&lt;br /&gt;
    ${Locate} &amp;quot;$INSTDIR&amp;quot; &amp;quot;/L=F /M=*.*&amp;quot; &amp;quot;un.DeleteFile&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    # finalize SHMessageBoxCheck&lt;br /&gt;
    ${SHMessageBoxCheckCleanup}&lt;br /&gt;
SectionEnd&lt;br /&gt;
&lt;br /&gt;
Function un.DeleteFile&lt;br /&gt;
  # show the message box&lt;br /&gt;
  ${SHMessageBoxCheck} &amp;quot;Remove additional files&amp;quot; \&lt;br /&gt;
                       &amp;quot;File `$R9` was not part of initial installation. Delete anyway?&amp;quot; \&lt;br /&gt;
                       ${MB_YESNO}|${MB_ICONQUESTION}&lt;br /&gt;
  &lt;br /&gt;
  # get the result&lt;br /&gt;
  Pop $0&lt;br /&gt;
  &lt;br /&gt;
  # delete if user clicked &amp;quot;Yes&amp;quot;&lt;br /&gt;
  StrCmp $0 ${IDYES} 0 +2&lt;br /&gt;
  Delete $R9&lt;br /&gt;
  &lt;br /&gt;
  Push 0 # required by ${Locate}&lt;br /&gt;
FunctionEnd&lt;br /&gt;
&amp;lt;/highlight-nsis&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The Script ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;highlight-nsis&amp;gt;&lt;br /&gt;
# SHMessageBoxCheck&lt;br /&gt;
#   Works like MessageBox but includes a checkbox that gives the user the option not to show the message box again.&lt;br /&gt;
#   In that case the return value (first value on the stack) is always set to the last user choice&lt;br /&gt;
#&lt;br /&gt;
# See&lt;br /&gt;
#   http://nsis.sourceforge.net/SHMessageBoxCheck   (documentation)&lt;br /&gt;
#   https://msdn.microsoft.com/de-de/library/windows/desktop/bb773836.aspx   (implementation details)&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# types to indicate the buttons displayed in the message box&lt;br /&gt;
!define MB_OK                0x00000000&lt;br /&gt;
!define MB_OKCANCEL          0x00000001&lt;br /&gt;
!define MB_ABORTRETRYIGNORE  0x00000002 # not officially supported, use at your own risk!&lt;br /&gt;
!define MB_YESNOCANCEL       0x00000003 # not officially supported, use at your own risk!&lt;br /&gt;
!define MB_YESNO             0x00000004&lt;br /&gt;
!define MB_RETRYCANCEL       0x00000005 # not officially supported, use at your own risk!&lt;br /&gt;
!define MB_CANCELTRYCONTINUE 0x00000006 # not officially supported, use at your own risk!&lt;br /&gt;
!define MB_HELP              0x00004000 # not officially supported, use at your own risk!&lt;br /&gt;
&lt;br /&gt;
# types to display an icon in the message box&lt;br /&gt;
!define MB_ICONHAND          0x00000010&lt;br /&gt;
!define MB_ICONQUESTION      0x00000020 # MS bug: Same as MB_ICONEXCLAMATION&lt;br /&gt;
!define MB_ICONEXCLAMATION   0x00000030&lt;br /&gt;
!define MB_ICONINFORMATION   0x00000040&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# return values&lt;br /&gt;
!define IDOK        1&lt;br /&gt;
!define IDCANCEL    2&lt;br /&gt;
!define IDABORT     3&lt;br /&gt;
!define IDRETRY     4&lt;br /&gt;
!define IDIGNORE    5&lt;br /&gt;
!define IDYES       6&lt;br /&gt;
!define IDNO        7&lt;br /&gt;
!define IDCONTINUE 11&lt;br /&gt;
!define IDTRYAGAIN 10&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# the user&amp;#039;s previous choice (i.e. the button clicked in the message box)&lt;br /&gt;
Var _lastReturnValue&lt;br /&gt;
&lt;br /&gt;
# The value that the call to SHMessageBoxCheck should return when the user chose not to display the message box again&lt;br /&gt;
!define _DEFAULT 9999&lt;br /&gt;
&lt;br /&gt;
# Windows XP does not expose the function name, so we have to specify the function by ordinal value&lt;br /&gt;
!ifdef NSIS_UNICODE&lt;br /&gt;
    !define _SHMessageBoxCheck_Ordinal 191&lt;br /&gt;
!else&lt;br /&gt;
    !define _SHMessageBoxCheck_Ordinal 185&lt;br /&gt;
!endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
!macro SHMessageBoxCheckInit _UNIQUE_STRING&lt;br /&gt;
    # SHMessageBoxCheck stores the user&amp;#039;s choice not to display the message box again in the registry, see&lt;br /&gt;
    #   HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain&lt;br /&gt;
    !ifdef _PSZ_REG_VAL&lt;br /&gt;
        !error &amp;quot;Only call SHMessageBoxCheckInit once and make sure to call SHMessageBoxCheckCleanup before using it again&amp;quot;&lt;br /&gt;
    !else&lt;br /&gt;
        # the unique string used to identify this message (and name of the registry value used to store the checkbox status)&lt;br /&gt;
        !define _PSZ_REG_VAL ${_UNIQUE_STRING}&lt;br /&gt;
    !endif&lt;br /&gt;
&lt;br /&gt;
    # make sure the registry value is not yet set (for whatever reason)&lt;br /&gt;
    ${SHMessageBoxCheckCleanup}&lt;br /&gt;
!macroend&lt;br /&gt;
!define SHMessageBoxCheckInit &amp;quot;!insertmacro SHMessageBoxCheckInit&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
!macro SHMessageBoxCheckCleanup&lt;br /&gt;
    # delete the registry key that is used to store the checkbox status so we can start fresh next time&lt;br /&gt;
    DeleteRegValue HKCU &amp;quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain&amp;quot; &amp;quot;${_PSZ_REG_VAL}&amp;quot;&lt;br /&gt;
!macroend&lt;br /&gt;
!define SHMessageBoxCheckCleanup &amp;quot;!insertmacro SHMessageBoxCheckCleanup&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
!macro SHMessageBoxCheck _CAPTION _TEXT _TYPE&lt;br /&gt;
    # this would be the simple way (by name)&lt;br /&gt;
    # System::Call &amp;quot;shlwapi::SHMessageBoxCheck(p $HWNDPARENT, t &amp;#039;${_TEXT}&amp;#039;, t &amp;#039;${_CAPTION}&amp;#039;, i ${_TYPE}, i ${_DEFAULT}, t &amp;#039;${_PSZ_REG_VAL}&amp;#039;) i .r0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    # for backwards-compatibility we get the process address by specifying the function&amp;#039;s ordinal value&lt;br /&gt;
    System::Call &amp;quot;kernel32::GetModuleHandle(t &amp;#039;shlwapi.dll&amp;#039;) p .s&amp;quot;&lt;br /&gt;
    System::Call &amp;quot;kernel32::GetProcAddress(p s, i ${_SHMessageBoxCheck_Ordinal}) p .r0&amp;quot;&lt;br /&gt;
    System::Call &amp;quot;::$0(p $HWNDPARENT, t &amp;#039;${_TEXT}&amp;#039;, t &amp;#039;${_CAPTION}&amp;#039;, i ${_TYPE}, i ${_DEFAULT}, t &amp;#039;${_PSZ_REG_VAL}&amp;#039;) i .r0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    # save the user&amp;#039;s choice (unless the default value was returned - then don&amp;#039;t update and return the saved choice)&lt;br /&gt;
    StrCmp $0 ${_DEFAULT} +2 0&lt;br /&gt;
        StrCpy $_lastReturnValue $0&lt;br /&gt;
&lt;br /&gt;
    # push the return value to the stack&lt;br /&gt;
    Push $_lastReturnValue&lt;br /&gt;
!macroend&lt;br /&gt;
!define SHMessageBoxCheck &amp;quot;!insertmacro SHMessageBoxCheck&amp;quot;&lt;br /&gt;
&amp;lt;/highlight-nsis&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface Functions]]&lt;br /&gt;
[[Category:Headers]]&lt;br /&gt;
[[Category:Code Examples]]&lt;/div&gt;</summary>
		<author><name>Ede 123</name></author>
	</entry>
</feed>