Added !getdllversion [Bug#2809308,RFE#1873767]

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6186 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2011-11-21 20:13:30 +00:00
parent 443e7f4dc2
commit 79dbea3321
5 changed files with 38 additions and 4 deletions

View file

@ -139,6 +139,15 @@ This command creates a temporary file. It puts its path into a define, named \e{
\c !undef FILE \c !undef FILE
\c !undef DATE \c !undef DATE
\S1{ppgetdllversion} !getdllversion
\c localfilename define_basename
This is similar to \R{getdllversionlocal}{GetDLLVersionLocal}, only it stores the version number in defines and can therefore be used anywhere, not just inside functions and sections.
\c !getdllversion "$%windir%\explorer.exe" expv_
\c !echo "Explorer.exe version is ${expv_1}.${expv_2}.${expv_3}.${expv_4}"
\S1{warning} !warning \S1{warning} !warning
\c [message] \c [message]

View file

@ -66,7 +66,7 @@ Gets the version information from the DLL (or any other executable containing ve
\c localfilename user_var(high dword output) user_var(low dword output) \c localfilename user_var(high dword output) user_var(low dword output)
This is similar to \R{getdllversion}{GetDLLVersion}, only it acts on the system building the installer (it actually compiles into two \R{StrCpy}{StrCpy} commands). Sets the two output variables with the DLL version information of the DLL on the build system. This is similar to \R{getdllversion}{GetDLLVersion}, only it acts on the system building the installer (it actually compiles into two \R{StrCpy}{StrCpy} commands). Sets the two output variables with the DLL version information of the DLL on the build system. Use \R{ppgetdllversion}{!getdllversion} if you need to use the values with \R{viproductversion}{VIProductVersion}.
\S2{getfiletime} GetFileTime \S2{getfiletime} GetFileTime

View file

@ -1384,6 +1384,28 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
} }
return PS_OK; return PS_OK;
case TOK_P_GETDLLVERSION:
{
const TCHAR *cmdname = _T("!getdllversion");
DWORD low, high;
if (!GetDLLVersion(line.gettoken_str(1), high, low))
{
ERROR_MSG(_T("%s: error reading version info from \"%s\"\n"), cmdname, line.gettoken_str(1));
return PS_ERROR;
}
TCHAR symbuf[MAX_LINELENGTH], numbuf[30], *basesymname = line.gettoken_str(2);
DWORD vals[] = { high>>16, high&0xffff, low>>16, low&0xffff };
SCRIPT_MSG(_T("%s: %s (%u.%u.%u.%u)->(%s<1..4>)\n"),
cmdname, line.gettoken_str(1), vals[0], vals[1], vals[2], vals[3], basesymname);
for (UINT i = 0; i < 4; ++i)
{
_stprintf(symbuf,_T("%s%u"), basesymname, i+1);
_stprintf(numbuf,_T("%u"), vals[i]);
definedlist.add(symbuf, numbuf);
}
}
return PS_OK;
// page ordering stuff // page ordering stuff
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_CONFIG_VISIBLE_SUPPORT
@ -5062,10 +5084,11 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
return add_entry(&ent); return add_entry(&ent);
case TOK_GETDLLVERSIONLOCAL: case TOK_GETDLLVERSIONLOCAL:
{ {
const TCHAR*cmdname=_T("GetDLLVersionLocal");
DWORD low, high; DWORD low, high;
if (!GetDLLVersion(line.gettoken_str(1),high,low)) if (!GetDLLVersion(line.gettoken_str(1),high,low))
{ {
ERROR_MSG(_T("GetDLLVersionLocal: error reading version info from \"%s\"\n"),line.gettoken_str(1)); ERROR_MSG(_T("%s: error reading version info from \"%s\"\n"),cmdname,line.gettoken_str(1));
return PS_ERROR; return PS_ERROR;
} }
ent.which=EW_ASSIGNVAR; ent.which=EW_ASSIGNVAR;
@ -5081,8 +5104,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
ent.offsets[2]=0; ent.offsets[2]=0;
ent.offsets[3]=0; ent.offsets[3]=0;
if (ent.offsets[0]<0) PRINTHELP() if (ent.offsets[0]<0) PRINTHELP()
SCRIPT_MSG(_T("GetDLLVersionLocal: %s (%u,%u)->(%s,%s)\n"), SCRIPT_MSG(_T("%s: %s (%u,%u)->(%s,%s)\n"),
line.gettoken_str(1),high,low,line.gettoken_str(2),line.gettoken_str(3)); cmdname,line.gettoken_str(1),high,low,line.gettoken_str(2),line.gettoken_str(3));
} }
return add_entry(&ent); return add_entry(&ent);
case TOK_GETFILETIMELOCAL: case TOK_GETFILETIMELOCAL:

View file

@ -270,6 +270,7 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_P_TEMPFILE,_T("!tempfile"),1,0,_T("symbol"),TP_ALL}, {TOK_P_TEMPFILE,_T("!tempfile"),1,0,_T("symbol"),TP_ALL},
{TOK_P_DELFILE,_T("!delfile"),1,1,_T("[/nonfatal] file"),TP_ALL}, {TOK_P_DELFILE,_T("!delfile"),1,1,_T("[/nonfatal] file"),TP_ALL},
{TOK_P_APPENDFILE,_T("!appendfile"),2,0,_T("file appended_line"),TP_ALL}, {TOK_P_APPENDFILE,_T("!appendfile"),2,0,_T("file appended_line"),TP_ALL},
{TOK_P_GETDLLVERSION,_T("!getdllversion"),2,0,_T("localfilename define_basename"),TP_ALL},
{TOK_P_SEARCHPARSESTRING,_T("!searchparse"),3,-1,_T("[/ignorecase] [/noerrors] [/file] source_string substring OUTPUTSYM1 [substring [OUTPUTSYM2 [substring ...]]]"),TP_ALL}, {TOK_P_SEARCHPARSESTRING,_T("!searchparse"),3,-1,_T("[/ignorecase] [/noerrors] [/file] source_string substring OUTPUTSYM1 [substring [OUTPUTSYM2 [substring ...]]]"),TP_ALL},
{TOK_P_SEARCHREPLACESTRING,_T("!searchreplace"),4,1,_T("[/ignorecase] output_name source_string substring replacestring"), TP_ALL}, {TOK_P_SEARCHREPLACESTRING,_T("!searchreplace"),4,1,_T("[/ignorecase] output_name source_string substring replacestring"), TP_ALL},

View file

@ -124,6 +124,7 @@ enum
TOK_P_TEMPFILE, TOK_P_TEMPFILE,
TOK_P_DELFILE, TOK_P_DELFILE,
TOK_P_APPENDFILE, TOK_P_APPENDFILE,
TOK_P_GETDLLVERSION,
TOK_P_SEARCHPARSESTRING, TOK_P_SEARCHPARSESTRING,
TOK_P_SEARCHREPLACESTRING, TOK_P_SEARCHREPLACESTRING,