MSWSP: remove unused tree_item's
[wireshark-wip.git] / packaging / nsis / common.nsh
blob0493e5ee620b37713b3779c3cde7297cbeac6600
2 ; ============================================================================
3 ; Name and version information
4 ; ============================================================================
6 !if ${WIRESHARK_TARGET_PLATFORM} == "win32"
7 !define BITS 32
8 !else
9 !define BITS 64
10 !endif
12 !define DISPLAY_NAME "${PROGRAM_NAME} ${VERSION} (${BITS}-bit)"
13 Name "${DISPLAY_NAME}"
15 !define UNINSTALLER_NAME "uninstall.exe"
17 VIAddVersionKey "ProductName" "${PROGRAM_NAME}"
18 VIAddVersionKey "Comments" "It's a great product with a great story to tell. I'm pumped!"
19 VIAddVersionKey "CompanyName" "${PROGRAM_NAME} development team"
20 ; NSIS handles the copyright symbol correctly using CP-1252 but not UTF-8.
21 VIAddVersionKey "LegalCopyright" "© Gerald Combs and many others"
22 VIAddVersionKey "LegalTrademarks" "Wireshark and the 'fin' logo are registered trademarks of the Wireshark Foundation"
23 VIAddVersionKey "FileDescription" "${PROGRAM_NAME} installer for ${BITS}-bit Windows"
24 VIAddVersionKey "Language" "English"
25 VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
26 VIAddVersionKey "FileVersion" "${PRODUCT_VERSION}"
27 VIProductVersion "${PRODUCT_VERSION}"
29 XPStyle on
32 ; ============================================================================
33 ; Functions and macros
34 ; ============================================================================
36 ; Used to refresh the display of file association
37 !define SHCNE_ASSOCCHANGED 0x08000000
38 !define SHCNF_IDLIST 0
40 !macro UpdateIcons
41     Push $R0
42     Push $R1
43     Push $R2
44     
45     !define UPDATEICONS_UNIQUE ${__LINE__}
46     
47     IfFileExists "$SYSDIR\shell32.dll" UpdateIcons.ok_shell32_${UPDATEICONS_UNIQUE} UpdateIcons.error_shell32_${UPDATEICONS_UNIQUE}
48 UpdateIcons.ok_shell32_${UPDATEICONS_UNIQUE}:
49     System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
50     Goto UpdateIcons.quit_${UPDATEICONS_UNIQUE}
52 UpdateIcons.error_shell32_${UPDATEICONS_UNIQUE}:
53     MessageBox MB_OK|MB_ICONSTOP  \
54         "Can't find 'shell32.dll' library. Impossible to update icons" \
55         /SD IDOK
56     Goto UpdateIcons.quit_${UPDATEICONS_UNIQUE}
58 UpdateIcons.quit_${UPDATEICONS_UNIQUE}:
59     !undef UPDATEICONS_UNIQUE
60     Pop $R2
61     Pop $R1
62     Pop $R0
64 ; Force the icon cache to refresh
65 ; http://superuser.com/questions/499078/refresh-icon-cache-without-rebooting
66 IfFileExists "$SYSDIR\ie4uinit.exe" 0 +2
67 Exec '"$SYSDIR\ie4uinit.exe" -ClearIconCache'
69 !macroend
71 ; ============================================================================
72 ; Push our known file extensions onto the stack, prepended with a marker
73 ; Note that this is a subset of dump_open_table in wiretap/file_access.c. We
74 ; probably don't want to grab JPEG or MP3 files.
75 ; ============================================================================
77 ; Used to add associations between file extensions and Wireshark
78 !define WIRESHARK_ASSOC "wireshark-capture-file"
80 !define FILE_EXTENSION_MARKER "FILE_EXTENSION_MARKER"
82 !macro PushFileExtensions
83     Push "${FILE_EXTENSION_MARKER}"
84     Push ".wpz"
85     Push ".wpc"
86     Push ".vwr"
87     Push ".trc"
88     Push ".trace"
89     Push ".tr1"
90     Push ".tpc"
91     Push ".syc"
92     Push ".snoop"
93     Push ".rf5"
94     Push ".pkt"
95     Push ".pcapng"
96     Push ".pcap"
97     Push ".out"
98     Push ".ntar"
99     Push ".fdc"
100     Push ".erf"
101     Push ".enc"
102     Push ".cap"
103     Push ".bfr"
104     Push ".atc"
105     Push ".apc"
106     Push ".acp"
107     Push ".5vw"
108 !macroend
110 !macro IsWiresharkRunning
111 ; See if Wireshark is running
112 ; http://nsis.sourceforge.net/Check_whether_your_application_is_running
113 ${Do}
115     System::Call 'kernel32::OpenMutex(i 0x100000, b 0, t "Global\${PROGRAM_NAME}-is-running-{9CA78EEA-EA4D-4490-9240-FC01FCEF464B}") i .R0'
116         IntCmp $R0 0 checkRunningSession
117         System::Call 'kernel32::CloseHandle(i $R0)'
118         Goto isRunning
120 checkRunningSession:
121     System::Call 'kernel32::OpenMutex(i 0x100000, b 0, t "${PROGRAM_NAME}-is-running-{9CA78EEA-EA4D-4490-9240-FC01FCEF464B}") i .R0'
122         IntCmp $R0 0 notRunning
123         System::Call 'kernel32::CloseHandle(i $R0)'
125 isRunning:
126     ; You'd better go catch it.
127     MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "${PROGRAM_NAME} or one of its associated programs is running.$\r$\nPlease close it first." /SD IDCANCEL IDRETRY continueChecking
128     Quit
130 notRunning:
131     ${ExitDo}
133 continueChecking:
134 ${Loop}
135 !macroend
138 ; Editor modelines  -  http://www.wireshark.org/tools/modelines.html
140 ; Local variables:
141 ; c-basic-offset: 4
142 ; tab-width: 8
143 ; indent-tabs-mode: nil
144 ; End:
146 ; vi: set shiftwidth=4 tabstop=8 expandtab:
147 ; :indentSize=4:tabSize=8:noTabs=true: