Added support for named Symbols sets.
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3336 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
ad498291cf
commit
fa3bdf5e17
7 changed files with 442 additions and 121 deletions
|
@ -176,6 +176,7 @@ Version History
|
|||
- Added option for compile & run
|
||||
- Added compressor setting option
|
||||
- Added support for lzma compression
|
||||
- Added named Symbols sets.
|
||||
|
||||
Copyright Information
|
||||
---------------------
|
||||
|
|
|
@ -31,6 +31,7 @@ NSCRIPTDATA g_sdata;
|
|||
NRESIZEDATA g_resize;
|
||||
NFINDREPLACE g_find;
|
||||
extern NTOOLBAR g_toolbar;
|
||||
int g_symbol_set_mode;
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmdShow) {
|
||||
MSG msg;
|
||||
|
@ -42,8 +43,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmd
|
|||
my_memset(&g_find,0,sizeof(NFINDREPLACE));
|
||||
g_sdata.hInstance=GetModuleHandle(0);
|
||||
g_sdata.script_alloced=false;
|
||||
g_sdata.defines = NULL;
|
||||
RestoreDefines();
|
||||
g_sdata.symbols = NULL;
|
||||
RestoreSymbols();
|
||||
|
||||
if (!InitBranding()) {
|
||||
MessageBox(0,NSISERROR,"Error",MB_ICONEXCLAMATION|MB_OK);
|
||||
|
@ -180,7 +181,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||
}
|
||||
case WM_DESTROY:
|
||||
{
|
||||
SaveDefines();
|
||||
SaveSymbols();
|
||||
SaveCompressor();
|
||||
SaveMRUList();
|
||||
SaveWindowPos(g_sdata.hwnd);
|
||||
|
@ -798,6 +799,53 @@ BOOL CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void EnableSymbolSetButtons(HWND hwndDlg)
|
||||
{
|
||||
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETCOUNT, 0, 0);
|
||||
if(n > 0) {
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDCLEAR), TRUE);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDSAVE), TRUE);
|
||||
}
|
||||
else {
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDCLEAR), FALSE);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDSAVE), FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void SetSymbols(HWND hwndDlg, char **symbols)
|
||||
{
|
||||
int i = 0;
|
||||
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_RESETCONTENT , 0, 0);
|
||||
if (symbols) {
|
||||
while (symbols[i]) {
|
||||
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_ADDSTRING, 0, (LPARAM)symbols[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
EnableSymbolSetButtons(hwndDlg);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDRIGHT), FALSE);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDLEFT), FALSE);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDDEL), FALSE);
|
||||
}
|
||||
|
||||
char **GetSymbols(HWND hwndDlg)
|
||||
{
|
||||
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETCOUNT, 0, 0);
|
||||
char **symbols = NULL;
|
||||
if(n > 0) {
|
||||
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, (n+1)*sizeof(char *));
|
||||
symbols = (char **)GlobalLock(hMem);
|
||||
for (int i = 0; i < n; i++) {
|
||||
int len = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXTLEN, (WPARAM)i, 0);
|
||||
symbols[i] = (char *)GlobalAlloc(GPTR, (len+1)*sizeof(char));
|
||||
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXT, (WPARAM)i, (LPARAM)symbols[i]);
|
||||
}
|
||||
symbols[n] = NULL;
|
||||
}
|
||||
|
||||
return symbols;
|
||||
}
|
||||
|
||||
BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||
switch(msg) {
|
||||
case WM_INITDIALOG:
|
||||
|
@ -810,18 +858,38 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
rv = SendDlgItemMessage(hwndDlg, IDC_COMPRESSOR, CB_SETCURSEL, (WPARAM)g_sdata.default_compressor, (LPARAM)0);
|
||||
|
||||
i = 0;
|
||||
if (g_sdata.defines) {
|
||||
while (g_sdata.defines[i]) {
|
||||
SendDlgItemMessage(hwndDlg, IDC_DEFINES, LB_ADDSTRING, 0, (LPARAM)g_sdata.defines[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDRIGHT), FALSE);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDLEFT), FALSE);
|
||||
SetSymbols(hwndDlg, g_sdata.symbols);
|
||||
SetFocus(GetDlgItem(hwndDlg, IDC_SYMBOL));
|
||||
break;
|
||||
}
|
||||
case WM_MAKENSIS_LOADSYMBOLSET:
|
||||
{
|
||||
char *name = (char *)wParam;
|
||||
char **symbols = LoadSymbolSet(name);
|
||||
HGLOBAL hMem;
|
||||
|
||||
SetSymbols(hwndDlg, symbols);
|
||||
if(symbols) {
|
||||
hMem = GlobalHandle(symbols);
|
||||
GlobalUnlock(hMem);
|
||||
GlobalFree(hMem);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_MAKENSIS_SAVESYMBOLSET:
|
||||
{
|
||||
char *name = (char *)wParam;
|
||||
char **symbols = GetSymbols(hwndDlg);
|
||||
HGLOBAL hMem;
|
||||
|
||||
if(symbols) {
|
||||
SaveSymbolSet(name, symbols);
|
||||
hMem = GlobalHandle(symbols);
|
||||
GlobalUnlock(hMem);
|
||||
GlobalFree(hMem);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch (LOWORD(wParam)) {
|
||||
|
@ -829,19 +897,10 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
{
|
||||
ResetObjects();
|
||||
ResetInputScript();
|
||||
ResetDefines();
|
||||
int n = SendDlgItemMessage(hwndDlg, IDC_DEFINES, LB_GETCOUNT, 0, 0);
|
||||
if(n > 0) {
|
||||
g_sdata.defines = (char **)GlobalAlloc(GPTR, (n+1)*sizeof(char *));
|
||||
for (int i = 0; i < n; i++) {
|
||||
int len = SendDlgItemMessage(hwndDlg, IDC_DEFINES, LB_GETTEXTLEN, (WPARAM)i, 0);
|
||||
g_sdata.defines[i] = (char *)GlobalAlloc(GPTR, (len+1)*sizeof(char));
|
||||
SendDlgItemMessage(hwndDlg, IDC_DEFINES, LB_GETTEXT, (WPARAM)i, (LPARAM)g_sdata.defines[i]);
|
||||
}
|
||||
g_sdata.defines[n] = NULL;
|
||||
}
|
||||
ResetSymbols();
|
||||
g_sdata.symbols = GetSymbols(hwndDlg);
|
||||
|
||||
n = SendDlgItemMessage(hwndDlg, IDC_COMPRESSOR, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
|
||||
int n = SendDlgItemMessage(hwndDlg, IDC_COMPRESSOR, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
|
||||
if (n >= (int)COMPRESSOR_SCRIPT && n <= (int)COMPRESSOR_BEST) {
|
||||
g_sdata.default_compressor = (NCOMPRESSOR)n;
|
||||
}
|
||||
|
@ -862,7 +921,7 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
char *buf = (char *)GlobalAlloc(GPTR, (n+1)*sizeof(char));
|
||||
SendDlgItemMessage(hwndDlg, IDC_SYMBOL, WM_GETTEXT, n+1, (LPARAM)buf);
|
||||
if(my_strstr(buf," ") || my_strstr(buf,"\t")) {
|
||||
MessageBox(hwndDlg,DEFINESERROR,"Error",MB_OK|MB_ICONSTOP);
|
||||
MessageBox(hwndDlg,SYMBOLSERROR,"Error",MB_OK|MB_ICONSTOP);
|
||||
GlobalFree(buf);
|
||||
break;
|
||||
}
|
||||
|
@ -877,21 +936,22 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
buf = buf3;
|
||||
GlobalFree(buf2);
|
||||
}
|
||||
SendDlgItemMessage(hwndDlg, IDC_DEFINES, LB_ADDSTRING, 0, (LPARAM)buf);
|
||||
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_ADDSTRING, 0, (LPARAM)buf);
|
||||
SendDlgItemMessage(hwndDlg, IDC_SYMBOL, WM_SETTEXT, 0, 0);
|
||||
SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_SETTEXT, 0, 0);
|
||||
GlobalFree(buf);
|
||||
EnableSymbolSetButtons(hwndDlg);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDLEFT:
|
||||
{
|
||||
int index = SendDlgItemMessage(hwndDlg, IDC_DEFINES, LB_GETCURSEL, 0, 0);
|
||||
int index = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETCURSEL, 0, 0);
|
||||
if(index != LB_ERR) {
|
||||
int n = SendDlgItemMessage(hwndDlg, IDC_DEFINES, LB_GETTEXTLEN, (WPARAM)index, 0);
|
||||
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXTLEN, (WPARAM)index, 0);
|
||||
if(n > 0) {
|
||||
char *buf = (char *)GlobalAlloc(GPTR, (n+1)*sizeof(char));
|
||||
SendDlgItemMessage(hwndDlg, IDC_DEFINES, LB_GETTEXT, (WPARAM)index, (LPARAM)buf);
|
||||
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXT, (WPARAM)index, (LPARAM)buf);
|
||||
char *p = my_strstr(buf,"=");
|
||||
if(p) {
|
||||
SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_SETTEXT, 0, (LPARAM)(p+1));
|
||||
|
@ -899,12 +959,44 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
SendDlgItemMessage(hwndDlg, IDC_SYMBOL, WM_SETTEXT, 0, (LPARAM)buf);
|
||||
GlobalFree(buf);
|
||||
SendDlgItemMessage(hwndDlg, IDC_DEFINES, LB_DELETESTRING, (WPARAM)index, (LPARAM)buf);
|
||||
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_DELETESTRING, (WPARAM)index, 0);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDLEFT), FALSE);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDDEL), FALSE);
|
||||
EnableSymbolSetButtons(hwndDlg);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDCLEAR:
|
||||
{
|
||||
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_RESETCONTENT , 0, 0);
|
||||
EnableSymbolSetButtons(hwndDlg);
|
||||
}
|
||||
break;
|
||||
case IDLOAD:
|
||||
{
|
||||
g_symbol_set_mode=1;
|
||||
DialogBox(g_sdata.hInstance,MAKEINTRESOURCE(DLG_SYMBOLSET),hwndDlg,(DLGPROC)SymbolSetProc);
|
||||
}
|
||||
break;
|
||||
case IDSAVE:
|
||||
{
|
||||
g_symbol_set_mode=2;
|
||||
DialogBox(g_sdata.hInstance,MAKEINTRESOURCE(DLG_SYMBOLSET),hwndDlg,(DLGPROC)SymbolSetProc);
|
||||
}
|
||||
break;
|
||||
case IDDEL:
|
||||
{
|
||||
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETSELCOUNT, 0, 0);
|
||||
int *items = (int *)GlobalAlloc(GPTR, n*sizeof(int));
|
||||
int rv = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETSELITEMS, (WPARAM)n, (LPARAM)items);
|
||||
int i;
|
||||
for(i=n-1;i>=0;i--) {
|
||||
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_DELETESTRING, (WPARAM)items[i], 0);
|
||||
}
|
||||
EnableSymbolSetButtons(hwndDlg);
|
||||
}
|
||||
break;
|
||||
case IDC_SYMBOL:
|
||||
if(HIWORD(wParam) == EN_CHANGE)
|
||||
{
|
||||
|
@ -917,15 +1009,21 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
}
|
||||
break;
|
||||
case IDC_DEFINES:
|
||||
case IDC_SYMBOLS:
|
||||
if(HIWORD(wParam) == LBN_SELCHANGE)
|
||||
{
|
||||
int n = SendDlgItemMessage(hwndDlg, IDC_DEFINES, LB_GETCURSEL, 0, 0);
|
||||
if(n != LB_ERR) {
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDLEFT), TRUE);
|
||||
}
|
||||
else {
|
||||
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETSELCOUNT, 0, 0);
|
||||
if(n == 0) {
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDLEFT), FALSE);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDDEL), FALSE);
|
||||
}
|
||||
else if(n == 1) {
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDLEFT), TRUE);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDDEL), TRUE);
|
||||
}
|
||||
else if(n > 1) {
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDLEFT), FALSE);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDDEL), TRUE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -980,6 +1078,114 @@ BOOL CALLBACK CompressorProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||
switch(msg) {
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
HWND hwndEdit;
|
||||
HKEY hKey;
|
||||
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDDEL), FALSE);
|
||||
if (RegOpenKeyEx(REGSEC,REGKEY,0,KEY_READ,&hKey) == ERROR_SUCCESS) {
|
||||
HKEY hSubKey;
|
||||
|
||||
if (RegCreateKey(hKey,REGSYMSUBKEY,&hSubKey) == ERROR_SUCCESS) {
|
||||
char subkey[1024];
|
||||
int i=0;
|
||||
|
||||
while (RegEnumKey(hSubKey,i,subkey,sizeof(subkey)) == ERROR_SUCCESS) {
|
||||
SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_ADDSTRING, 0, (LPARAM)subkey);
|
||||
i++;
|
||||
}
|
||||
RegCloseKey(hSubKey);
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), 0, 0, 0); // Handle of list
|
||||
hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), hwndEdit, 0, 0); //Handle of edit box
|
||||
SendMessage(hwndEdit, EM_LIMITTEXT, (WPARAM)SYMBOL_SET_NAME_MAXLEN, 0);
|
||||
if(g_symbol_set_mode == 1) { //Load
|
||||
SetWindowText(hwndDlg, LOAD_SYMBOL_SET_DLG_NAME);
|
||||
SendMessage(hwndEdit, EM_SETREADONLY, (WPARAM)TRUE, 0);
|
||||
}
|
||||
else {
|
||||
SetWindowText(hwndDlg, SAVE_SYMBOL_SET_DLG_NAME);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
{
|
||||
HWND hwndEdit;
|
||||
char name[SYMBOL_SET_NAME_MAXLEN+1];
|
||||
|
||||
hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), 0, 0, 0); // Handle of list
|
||||
hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), hwndEdit, 0, 0); //Handle of edit box
|
||||
SendMessage(hwndEdit, WM_GETTEXT, (WPARAM)SYMBOL_SET_NAME_MAXLEN+1, (LPARAM)name);
|
||||
if(!lstrlen(name)) {
|
||||
if(g_symbol_set_mode == 1) { //Load
|
||||
MessageBox(hwndDlg,LOAD_SYMBOL_SET_MESSAGE,LOAD_SYMBOL_SET_DLG_NAME,MB_OK|MB_ICONEXCLAMATION);
|
||||
}
|
||||
else {
|
||||
MessageBox(hwndDlg,SAVE_SYMBOL_SET_MESSAGE,SAVE_SYMBOL_SET_DLG_NAME,MB_OK|MB_ICONEXCLAMATION);
|
||||
}
|
||||
}
|
||||
else {
|
||||
HWND hwndParent = GetParent(hwndDlg);
|
||||
if(g_symbol_set_mode == 1) { //Load
|
||||
SendMessage(hwndParent, WM_MAKENSIS_LOADSYMBOLSET, (WPARAM)name, NULL);
|
||||
}
|
||||
else {
|
||||
SendMessage(hwndParent, WM_MAKENSIS_SAVESYMBOLSET, (WPARAM)name, NULL);
|
||||
}
|
||||
EndDialog(hwndDlg, TRUE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IDCANCEL:
|
||||
{
|
||||
EndDialog(hwndDlg, TRUE);
|
||||
break;
|
||||
}
|
||||
case IDDEL:
|
||||
{
|
||||
int n = SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETCURSEL, 0, 0);
|
||||
if(n != CB_ERR) {
|
||||
long len = SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETLBTEXTLEN, (WPARAM)n, 0);
|
||||
char *buf = (char *)GlobalAlloc(GPTR, (len+1)*sizeof(char));
|
||||
if(SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETLBTEXT, (WPARAM)n, (LPARAM)buf) != CB_ERR) {
|
||||
SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_DELETESTRING, n, 0);
|
||||
DeleteSymbolSet(buf);
|
||||
}
|
||||
GlobalFree(buf);
|
||||
}
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDDEL), FALSE);
|
||||
break;
|
||||
}
|
||||
case IDC_NAMES:
|
||||
{
|
||||
if(HIWORD(wParam) == CBN_SELCHANGE)
|
||||
{
|
||||
int n = SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETCURSEL, 0, 0);
|
||||
if(n == CB_ERR) {
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDDEL), FALSE);
|
||||
}
|
||||
else {
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDDEL), TRUE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void SetCompressor(NCOMPRESSOR compressor)
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -39,14 +39,13 @@
|
|||
#define LOCALDOCS "\\NSIS.chm"
|
||||
#define NSISERROR "Unable to intialize MakeNSIS. Please verify that makensis.exe is in the same directory as makensisw.exe."
|
||||
#define DLGERROR "Unable to intialize MakeNSISW."
|
||||
#define DEFINESERROR "Symbol cannot contain whitespace characters"
|
||||
#define SYMBOLSERROR "Symbol cannot contain whitespace characters"
|
||||
#define NSISUPDATEPROMPT "Running NSIS Update will close MakeNSISW.\nContinue?"
|
||||
#define REGSEC HKEY_LOCAL_MACHINE
|
||||
#define REGKEY "Software\\NSIS"
|
||||
#define REGLOC "MakeNSISWPlacement"
|
||||
#define REGCOMPRESSOR "MakeNSISWCompressor"
|
||||
#define REGDEFSUBKEY "Defines"
|
||||
#define REGDEFCOUNT "MakeNSISWDefinesCount"
|
||||
#define REGSYMSUBKEY "Symbols"
|
||||
#define REGMRUSUBKEY "MRU"
|
||||
#define EXENAME "makensis.exe"
|
||||
#define MAX_STRING 256
|
||||
|
@ -61,8 +60,15 @@
|
|||
#define RESTORED_COMPRESSOR_MESSAGE "\n\nThe %s compressor (%d bytes) created the smallest installer which was restored."
|
||||
#define EXE_HEADER_COMPRESSOR_STAT "EXE header size:"
|
||||
#define TOTAL_SIZE_COMPRESSOR_STAT "Total size:"
|
||||
#define SYMBOL_SET_NAME_MAXLEN 40
|
||||
#define LOAD_SYMBOL_SET_DLG_NAME "Load Symbol Definitions Set"
|
||||
#define SAVE_SYMBOL_SET_DLG_NAME "Save Symbol Definitions Set"
|
||||
#define LOAD_SYMBOL_SET_MESSAGE "Please select a name for the Symbol Definitions Set to load."
|
||||
#define SAVE_SYMBOL_SET_MESSAGE "Please enter a name for the Symbol Definitions Set to save."
|
||||
|
||||
#define WM_MAKENSIS_PROCESSCOMPLETE (WM_USER+1001)
|
||||
#define WM_MAKENSIS_LOADSYMBOLSET (WM_USER+1002)
|
||||
#define WM_MAKENSIS_SAVESYMBOLSET (WM_USER+1003)
|
||||
|
||||
enum {
|
||||
MAKENSIS_NOTIFY_SCRIPT,
|
||||
|
@ -120,12 +126,16 @@ BOOL CALLBACK DialogResize(HWND hWnd, LPARAM /* unused*/);
|
|||
BOOL CALLBACK AboutNSISProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
BOOL CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
BOOL CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
BOOL CALLBACK CompressorProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
void CompileNSISScript();
|
||||
char* BuildDefines();
|
||||
char* BuildSymbols();
|
||||
void SetCompressor(NCOMPRESSOR);
|
||||
void RestoreDefines();
|
||||
void SaveDefines();
|
||||
void RestoreSymbols();
|
||||
void SaveSymbols();
|
||||
void DeleteSymbolSet(char *);
|
||||
char** LoadSymbolSet(char *);
|
||||
void SaveSymbolSet(char *, char **);
|
||||
void RestoreMRUList();
|
||||
void SaveMRUList();
|
||||
|
||||
|
@ -136,7 +146,7 @@ typedef struct NSISScriptData {
|
|||
char *input_script;
|
||||
char *branding;
|
||||
char *brandingv;
|
||||
char **defines;
|
||||
char **symbols;
|
||||
int retcode;
|
||||
DWORD logLength;
|
||||
DWORD warnings;
|
||||
|
|
|
@ -5,8 +5,11 @@
|
|||
#define IDS_LOADSCRIPT 1
|
||||
#define IDS_SAVE 2
|
||||
#define IDS_EXIT 3
|
||||
#define IDLOAD 3
|
||||
#define IDS_COPY 4
|
||||
#define IDSAVE 4
|
||||
#define IDS_FIND 5
|
||||
#define IDCLEAR 5
|
||||
#define IDS_RECOMPILE 6
|
||||
#define IDS_SETTINGS 7
|
||||
#define IDS_COMPRESSOR 8
|
||||
|
@ -35,6 +38,7 @@
|
|||
#define IDB_BITMAP1 120
|
||||
#define IDB_TOOLBAR 122
|
||||
#define DLG_COMPRESSOR 124
|
||||
#define DLG_SYMBOLSET 125
|
||||
#define IDC_LOGWIN 402
|
||||
#define IDC_VERSION 405
|
||||
#define IDC_CLOSE 406
|
||||
|
@ -56,9 +60,11 @@
|
|||
#define IDC_VALUE 1018
|
||||
#define IDRIGHT 1019
|
||||
#define IDLEFT 1020
|
||||
#define IDC_DEFINES 1021
|
||||
#define IDC_SYMBOLS 1021
|
||||
#define IDC_RECOMPILE_TEST 1022
|
||||
#define IDC_COMPRESSOR 1025
|
||||
#define IDC_NAMES 1027
|
||||
#define IDDEL 1028
|
||||
#define IDM_COMPRESSOR 40001
|
||||
#define IDM_TEST 40002
|
||||
#define IDM_EDITSCRIPT 40003
|
||||
|
@ -81,12 +87,12 @@
|
|||
#define IDM_SETTINGS 40033
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 125
|
||||
#define _APS_NEXT_RESOURCE_VALUE 126
|
||||
#define _APS_NEXT_COMMAND_VALUE 40034
|
||||
#define _APS_NEXT_CONTROL_VALUE 1027
|
||||
#define _APS_NEXT_CONTROL_VALUE 1029
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -175,27 +175,32 @@ BEGIN
|
|||
CONTROL 115,IDC_STATIC,"Static",SS_BITMAP,0,0,20,20
|
||||
END
|
||||
|
||||
DLG_SETTINGS DIALOGEX 0, 0, 250, 190
|
||||
DLG_SETTINGS DIALOGEX 0, 0, 284, 214
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "MakeNSISW Settings"
|
||||
FONT 8, "MS Sans Serif"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "&OK",IDOK,145,168,48,14
|
||||
PUSHBUTTON "&Cancel",IDCANCEL,195,168,48,14
|
||||
EDITTEXT IDC_SYMBOL,11,98,74,12,ES_AUTOHSCROLL,WS_EX_CLIENTEDGE
|
||||
EDITTEXT IDC_VALUE,11,124,74,12,ES_AUTOHSCROLL,WS_EX_CLIENTEDGE
|
||||
PUSHBUTTON ">",IDRIGHT,95,102,14,14
|
||||
PUSHBUTTON "<",IDLEFT,95,117,14,14
|
||||
LTEXT "Symbol",IDC_STATIC,11,89,24,8
|
||||
LTEXT "Value (optional)",IDC_STATIC,11,115,50,8
|
||||
LISTBOX IDC_DEFINES,117,77,121,79,LBS_NOINTEGRALHEIGHT |
|
||||
WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,WS_EX_CLIENTEDGE
|
||||
GROUPBOX "Symbol Definitions",IDC_STATIC,7,58,236,103
|
||||
LTEXT "Symbol List",IDC_STATIC,117,67,118,9
|
||||
GROUPBOX "Compressor Setting",IDC_STATIC,7,7,236,41
|
||||
DEFPUSHBUTTON "&OK",IDOK,177,193,48,14
|
||||
PUSHBUTTON "&Cancel",IDCANCEL,228,193,48,14
|
||||
EDITTEXT IDC_SYMBOL,13,117,74,12,ES_AUTOHSCROLL,WS_EX_CLIENTEDGE
|
||||
EDITTEXT IDC_VALUE,13,143,74,12,ES_AUTOHSCROLL,WS_EX_CLIENTEDGE
|
||||
PUSHBUTTON "Update >>",IDRIGHT,98,121,49,12
|
||||
PUSHBUTTON "Edit <<",IDLEFT,98,137,49,12
|
||||
LTEXT "Symbol",IDC_STATIC,13,108,24,8
|
||||
LTEXT "Value (optional)",IDC_STATIC,13,134,50,8
|
||||
LISTBOX IDC_SYMBOLS,154,98,121,79,LBS_NOINTEGRALHEIGHT |
|
||||
LBS_EXTENDEDSEL | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,
|
||||
WS_EX_CLIENTEDGE
|
||||
GROUPBOX "Symbol Definitions",IDC_STATIC,7,58,270,121
|
||||
LTEXT "Symbol List",IDC_STATIC,154,86,118,9
|
||||
GROUPBOX "Compressor Setting",IDC_STATIC,7,7,270,41
|
||||
LTEXT "Compressor:",IDC_STATIC,11,27,41,11
|
||||
COMBOBOX IDC_COMPRESSOR,55,26,184,94,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "Delete",IDDEL,98,153,49,12
|
||||
PUSHBUTTON "&Load",IDLOAD,178,63,48,14
|
||||
PUSHBUTTON "&Save",IDSAVE,228,63,48,14
|
||||
PUSHBUTTON "Clea&r",IDCLEAR,128,63,48,14
|
||||
END
|
||||
|
||||
DLG_COMPRESSOR DIALOG DISCARDABLE 0, 0, 250, 47
|
||||
|
@ -210,6 +215,19 @@ BEGIN
|
|||
WS_TABSTOP
|
||||
END
|
||||
|
||||
DLG_SYMBOLSET DIALOG DISCARDABLE 0, 0, 186, 124
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
|
||||
CAPTION "Dialog"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,76,103,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,129,103,50,14
|
||||
COMBOBOX IDC_NAMES,7,17,172,80,CBS_SIMPLE | CBS_AUTOHSCROLL |
|
||||
CBS_SORT | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Symbol Definitions Set Name:",IDC_STATIC,7,7,101,10
|
||||
PUSHBUTTON "&Delete",IDDEL,23,103,50,14
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -233,9 +251,9 @@ BEGIN
|
|||
DLG_SETTINGS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 243
|
||||
RIGHTMARGIN, 277
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 183
|
||||
BOTTOMMARGIN, 207
|
||||
END
|
||||
|
||||
DLG_COMPRESSOR, DIALOG
|
||||
|
@ -245,6 +263,14 @@ BEGIN
|
|||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 40
|
||||
END
|
||||
|
||||
DLG_SYMBOLSET, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 179
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 117
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
|
|
@ -267,7 +267,7 @@ void CompileNSISScript() {
|
|||
}
|
||||
if (!g_sdata.appended) {
|
||||
if (s) GlobalFree(s);
|
||||
char *defines = BuildDefines();
|
||||
char *symbols = BuildSymbols();
|
||||
|
||||
char compressor[40];
|
||||
if(lstrlen(g_sdata.compressor_name)) {
|
||||
|
@ -277,9 +277,9 @@ void CompileNSISScript() {
|
|||
lstrcpy(compressor,"");
|
||||
}
|
||||
|
||||
s = (char *)GlobalAlloc(GPTR, lstrlen(g_sdata.script)+lstrlen(defines)+lstrlen(compressor)+sizeof(EXENAME)+sizeof(" /NOTIFYHWND ")+20);
|
||||
wsprintf(s,"%s %s%s /NOTIFYHWND %d %s",EXENAME,compressor,defines,g_sdata.hwnd,g_sdata.script);
|
||||
GlobalFree(defines);
|
||||
s = (char *)GlobalAlloc(GPTR, lstrlen(g_sdata.script)+lstrlen(symbols)+lstrlen(compressor)+sizeof(EXENAME)+sizeof(" /NOTIFYHWND ")+20);
|
||||
wsprintf(s,"%s %s%s /NOTIFYHWND %d %s",EXENAME,compressor,symbols,g_sdata.hwnd,g_sdata.script);
|
||||
GlobalFree(symbols);
|
||||
if (g_sdata.script_alloced) GlobalFree(g_sdata.script);
|
||||
g_sdata.script_alloced = true;
|
||||
g_sdata.script = s;
|
||||
|
@ -322,62 +322,131 @@ void SaveWindowPos(HWND hwnd) {
|
|||
}
|
||||
}
|
||||
|
||||
void RestoreDefines()
|
||||
void RestoreSymbols()
|
||||
{
|
||||
HKEY hKey;
|
||||
HKEY hSubKey;
|
||||
if (RegOpenKeyEx(REGSEC,REGKEY,0,KEY_READ,&hKey) == ERROR_SUCCESS) {
|
||||
int n = 0;
|
||||
DWORD l = sizeof(n);
|
||||
DWORD t;
|
||||
if ((RegQueryValueEx(hKey,REGDEFCOUNT,NULL,&t,(unsigned char*)&n,&l)==ERROR_SUCCESS)&&(t == REG_DWORD)&&(l==sizeof(n))) {
|
||||
if(n > 0) {
|
||||
if (RegCreateKey(hKey,REGDEFSUBKEY,&hSubKey) == ERROR_SUCCESS) {
|
||||
char buf[8];
|
||||
g_sdata.defines = (char **)GlobalAlloc(GPTR, (n+1)*sizeof(char *));
|
||||
if (g_sdata.defines)
|
||||
{
|
||||
for(int i = 0; i < n; i++) {
|
||||
wsprintf(buf,"%d",i);
|
||||
l = 0;
|
||||
if ((RegQueryValueEx(hSubKey,buf,NULL,&t,NULL,&l)==ERROR_SUCCESS)&&(t == REG_SZ)) {
|
||||
l++;
|
||||
g_sdata.defines[i] = (char *)GlobalAlloc(GPTR, l*sizeof(char));
|
||||
if (g_sdata.defines[i])
|
||||
RegQueryValueEx(hSubKey,buf,NULL,&t,(unsigned char*)g_sdata.defines[i],&l);
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_sdata.defines[n] = NULL;
|
||||
}
|
||||
RegCloseKey(hSubKey);
|
||||
}
|
||||
}
|
||||
g_sdata.symbols = LoadSymbolSet(NULL);
|
||||
}
|
||||
|
||||
void SaveSymbols()
|
||||
{
|
||||
SaveSymbolSet(NULL, g_sdata.symbols);
|
||||
}
|
||||
|
||||
void DeleteSymbolSet(char *name)
|
||||
{
|
||||
if(name) {
|
||||
HKEY hKey;
|
||||
if (RegOpenKeyEx(REGSEC,REGKEY,0,KEY_READ,&hKey) == ERROR_SUCCESS) {
|
||||
char subkey[1024];
|
||||
wsprintf(subkey,"%s\\%s",REGSYMSUBKEY,name);
|
||||
RegDeleteKey(hKey,subkey);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
|
||||
void SaveDefines()
|
||||
char** LoadSymbolSet(char *name)
|
||||
{
|
||||
HKEY hKey;
|
||||
HKEY hSubKey;
|
||||
char **symbols = NULL;
|
||||
if (RegOpenKeyEx(REGSEC,REGKEY,0,KEY_READ,&hKey) == ERROR_SUCCESS) {
|
||||
char subkey[1024];
|
||||
if(name) {
|
||||
wsprintf(subkey,"%s\\%s",REGSYMSUBKEY,name);
|
||||
}
|
||||
else {
|
||||
lstrcpy(subkey,REGSYMSUBKEY);
|
||||
}
|
||||
if (RegCreateKey(hKey,subkey,&hSubKey) == ERROR_SUCCESS) {
|
||||
char buf[8];
|
||||
DWORD l;
|
||||
DWORD t;
|
||||
DWORD bufSize;
|
||||
DWORD i = 0;
|
||||
HGLOBAL hMem;
|
||||
|
||||
while(TRUE) {
|
||||
l = 0;
|
||||
bufSize = sizeof(buf);
|
||||
if ((RegEnumValue(hSubKey,i, buf, &bufSize,NULL,&t,NULL,&l)==ERROR_SUCCESS)&&(t == REG_SZ)) {
|
||||
if(symbols) {
|
||||
GlobalUnlock(hMem);
|
||||
hMem = GlobalReAlloc(hMem, (i+2)*sizeof(char *), GMEM_MOVEABLE|GMEM_ZEROINIT);
|
||||
symbols = (char **)GlobalLock(hMem);
|
||||
}
|
||||
else {
|
||||
hMem = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, (i+2)*sizeof(char *));
|
||||
symbols = (char **)GlobalLock(hMem);
|
||||
}
|
||||
if(symbols) {
|
||||
l++;
|
||||
symbols[i] = (char *)GlobalAlloc(GPTR, l*sizeof(char));
|
||||
if (symbols[i]) {
|
||||
RegQueryValueEx(hSubKey,buf,NULL,&t,(unsigned char*)symbols[i],&l);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
symbols[i] = NULL;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
RegCloseKey(hSubKey);
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
return symbols;
|
||||
}
|
||||
|
||||
void SaveSymbolSet(char *name, char **symbols)
|
||||
{
|
||||
HKEY hKey;
|
||||
HKEY hSubKey;
|
||||
int n = 0;
|
||||
if (RegCreateKey(REGSEC,REGKEY,&hKey) == ERROR_SUCCESS) {
|
||||
RegDeleteKey(hKey,REGDEFSUBKEY);
|
||||
if(g_sdata.defines) {
|
||||
if (RegCreateKey(hKey,REGDEFSUBKEY,&hSubKey) == ERROR_SUCCESS) {
|
||||
char subkey[1024];
|
||||
if(name) {
|
||||
wsprintf(subkey,"%s\\%s",REGSYMSUBKEY,name);
|
||||
}
|
||||
else {
|
||||
lstrcpy(subkey,REGSYMSUBKEY);
|
||||
}
|
||||
|
||||
if (RegOpenKey(hKey,subkey,&hSubKey) == ERROR_SUCCESS) {
|
||||
char buf[8];
|
||||
DWORD l;
|
||||
while(TRUE) {
|
||||
l = sizeof(buf);
|
||||
if (RegEnumValue(hSubKey,0, buf, &l,NULL,NULL,NULL,NULL)==ERROR_SUCCESS) {
|
||||
RegDeleteValue(hSubKey,buf);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
RegCloseKey(hSubKey);
|
||||
}
|
||||
if(symbols) {
|
||||
if (RegCreateKey(hKey,subkey,&hSubKey) == ERROR_SUCCESS) {
|
||||
char buf[8];
|
||||
while(g_sdata.defines[n]) {
|
||||
n = 0;
|
||||
while(symbols[n]) {
|
||||
wsprintf(buf,"%d",n);
|
||||
RegSetValueEx(hSubKey,buf,0,REG_SZ,(CONST BYTE *)g_sdata.defines[n],lstrlen(g_sdata.defines[n])+1);
|
||||
RegSetValueEx(hSubKey,buf,0,REG_SZ,(CONST BYTE *)symbols[n],lstrlen(symbols[n])+1);
|
||||
n++;
|
||||
}
|
||||
RegCloseKey(hSubKey);
|
||||
}
|
||||
}
|
||||
RegSetValueEx(hKey,REGDEFCOUNT,0,REG_DWORD,(CONST BYTE *)&n,sizeof(n));
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
|
@ -389,15 +458,18 @@ void ResetObjects() {
|
|||
g_sdata.thread = NULL;
|
||||
}
|
||||
|
||||
void ResetDefines() {
|
||||
if(g_sdata.defines) {
|
||||
void ResetSymbols() {
|
||||
if(g_sdata.symbols) {
|
||||
HGLOBAL hMem;
|
||||
int i = 0;
|
||||
while(g_sdata.defines[i]) {
|
||||
GlobalFree(g_sdata.defines[i]);
|
||||
while(g_sdata.symbols[i]) {
|
||||
GlobalFree(g_sdata.symbols[i]);
|
||||
i++;
|
||||
}
|
||||
GlobalFree(g_sdata.defines);
|
||||
g_sdata.defines = NULL;
|
||||
hMem = GlobalHandle(g_sdata.symbols);
|
||||
GlobalUnlock(hMem);
|
||||
GlobalFree(hMem);
|
||||
g_sdata.symbols = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -507,22 +579,22 @@ void ShowDocs() {
|
|||
ShellExecute(g_sdata.hwnd,"open",DOCPATH,NULL,NULL,SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
char* BuildDefines()
|
||||
char* BuildSymbols()
|
||||
{
|
||||
char *buf = NULL;
|
||||
|
||||
if(g_sdata.defines) {
|
||||
if(g_sdata.symbols) {
|
||||
int i=0;
|
||||
while(g_sdata.defines[i]) {
|
||||
while(g_sdata.symbols[i]) {
|
||||
if(buf) {
|
||||
char *buf3 = (char *)GlobalAlloc(GPTR,(lstrlen(buf)+lstrlen(g_sdata.defines[i])+6)*sizeof(char));
|
||||
wsprintf(buf3,"%s \"/D%s\"",buf,g_sdata.defines[i]);
|
||||
char *buf3 = (char *)GlobalAlloc(GPTR,(lstrlen(buf)+lstrlen(g_sdata.symbols[i])+6)*sizeof(char));
|
||||
wsprintf(buf3,"%s \"/D%s\"",buf,g_sdata.symbols[i]);
|
||||
GlobalFree(buf);
|
||||
buf = buf3;
|
||||
}
|
||||
else {
|
||||
buf = (char *)GlobalAlloc(GPTR,(lstrlen(g_sdata.defines[i])+5)*sizeof(char));
|
||||
wsprintf(buf,"\"/D%s\"",g_sdata.defines[i]);
|
||||
buf = (char *)GlobalAlloc(GPTR,(lstrlen(g_sdata.symbols[i])+5)*sizeof(char));
|
||||
wsprintf(buf,"\"/D%s\"",g_sdata.symbols[i]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ void EnableItems(HWND hwnd);*/
|
|||
void RestoreWindowPos(HWND hwnd);
|
||||
void SaveWindowPos(HWND hwnd);
|
||||
void ResetObjects();
|
||||
void ResetDefines();
|
||||
void ResetSymbols();
|
||||
int InitBranding();
|
||||
void InitTooltips(HWND h);
|
||||
void DestroyTooltips();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue