Winamp Forums A little help would be appriciated

 5th August 2003, 17:55 #1 TonyDS Senior Member   Join Date: Jul 2003 Posts: 148 A little help would be appriciated Before installation of My NSIS program is it possible to check the version of an exisiting exe to see if its the correct version? I don't really mean by checking it through the Reg though, as this does not show the correct version info. The original game is version 1.0.0.0, there are two updates for this game which will change the version to 2.0.0.1 or 2.0.0.2 I only want my NSIS program to install if the version is 2.0.0.2 otherwize you will get a message saying that you will need to update the game before you can install my NSIS program then quit If it is the correct version it will install normally At the momment My NSIS program checks the reg to see if the game is the correct version then installs using this bit of script PHP Code:  Function .onInit ReadRegStr $0 HKLM "SOFTWARE\\Game software\\v1.0" "Version" IntCmp$0 1 +1 +1 +3 MessageBox MB_ICONINFORMATION|MB_OK "WARNING: GAME needs to be updated to version 2.02." Abort FunctionEnd   This is fine, but my NSIS program will install if the Games 2.01 update has been installed, which will bugger up the entire installation and make the game unplayable See in the Reg the "version" is either 1 for the original or 2 if either update has been added. Which makes checking the reg pointless Like I said the only real way to check this would be from the Games EXE as this shows the true version. Any help would be greatly appriciated plus showing me how the script should look Thanks in advance -Tony
 5th August 2003, 17:58 #2 Joost Verburg NSIS MUI Dev   Join Date: Nov 2001 Posts: 3,717 So you need to check the version information resource? It could be possible using the System plug-in or you can write your own plug-in. Is there no registry key / configuration file available with the version number?
 5th August 2003, 18:19 #3 TonyDS Senior Member   Join Date: Jul 2003 Posts: 148 Yes it shows the version number HKLM "SOFTWARE\Game software\v1.0" "Version" 1.0 but if the game updates are applied it only shows to 2.0 so even if the 2.01 patch is install my program will still install, which I don't want it to do Thats why I would like to check the exe which shows the exact version. As I'm new to all this I have no way of knowing how to write a plug-in or which commands to use if any sorry, just a thick noobie
 5th August 2003, 20:16 #4 Afrow UK Moderator     Join Date: Nov 2002 Location: Birmingham, England Posts: 8,216 NSIS plugins are usually written in C++/Delphi. If you do not know about creating you're own plugin, then the System plugin will do your job. You should also try using the SysInfo plugin (get on NSIS Archive) which can get the version of specified files. -Stu Need an installer? http://www.afrowsoft.co.uk
 5th August 2003, 21:03 #5 TonyDS Senior Member   Join Date: Jul 2003 Posts: 148 I don't know how to use it though This is the reason, I'm asking for help Its not too much to ask
 5th August 2003, 21:24 #6 Afrow UK Moderator     Join Date: Nov 2002 Location: Birmingham, England Posts: 8,216 http://nsis.sourceforge.net/archive/...ysinfo.dll.zip Extract just the dll to your Plugins dir. Now, in your script use: sysinfo::GetFileVersion "x:\path\to\exe" Pop $0 ;file version If$0 is empty ("") then try: sysinfo::GetFileVersionValue "FileVersion" "x:\path\to\exe" Pop $0 ;file version -Stu Need an installer? http://www.afrowsoft.co.uk  6th August 2003, 02:10 #7 TonyDS Senior Member Join Date: Jul 2003 Posts: 148 Thanks for pointing me in the right direction Afrow UK I figured out how to use the script you provided but the next bit was a liitle harder PHP Code:  Function .onInit sysinfo::GetFileVersion "x:\\path\to\\exe" Pop$0 StrCmp $0 "2.0.0.2" +3 MessageBox MB_ICONINFORMATION|MB_OK "The Game has not yet been updated to version 2.02." Abort FunctionEnd  It was this bit StrCmp$0 "2.0.0.2" +3 that had me a little perplexed, it's taken me around 3 hrs just to figure that line out. Tried god knows how many differrent combinations of IntCmp, IntCmpU, StrCpy plus a few others, I was about to give up on it, when I came upon the combination above which works. So once again thanks
 6th August 2003, 09:42 #8 Afrow UK Moderator     Join Date: Nov 2002 Location: Birmingham, England Posts: 8,216 Just a thought, what happens if 2.0.0.3 comes out. You're installer will think that the user has an older version. You should remove the dot (.) from the version, and use IntCmp instead. To remove the dots, use the StrReplace function: code:Push $0 ;input Push "." ;to replace Push "" ;replace with nothing (remove) Call StrReplace Pop$0 IntCmp $0 2002 +3 0 +3 MessageBox MB_ICONINFORMATION|MB_OK "The Game has not yet been updated to version 2.02." Abort IntCmp works like this: IntCmp$0 2002 [goto if $0=2002] [goto if$0<2002] [goto if $0>2002] -Stu Need an installer? http://www.afrowsoft.co.uk  6th August 2003, 12:29 #9 Sunjammer Major Dude Join Date: Jun 2002 Location: Swindon, UK Posts: 559 How about using the code Smile2Me created ages ago to compare dotted versions? http://nsis.sourceforge.net/archive/....php?pageid=57  6th August 2003, 12:51 #10 SteelCoder Junior Member Join Date: May 2003 Location: Charleston, SC Posts: 11 If the executable has an actual 'version' resource in it (and it's maintained correctly), Couldn't you use GetDLLVersion?  6th August 2003, 14:40 #11 ramon18 NSIS Dev Join Date: Apr 2003 Location: Portugal Posts: 110 Yes, you can use GetDLLVersion, for example you can use the previous uninstall.exe version info, by detecting the file location through the registry and than decide if the update can run or not. good luck  6th August 2003, 17:41 #12 SteelCoder Junior Member Join Date: May 2003 Location: Charleston, SC Posts: 11 Why not just compare the version of the file you are going to install verses the file that is installed? Just like upgrading a DLL.  6th August 2003, 19:19 #13 TonyDS Senior Member Join Date: Jul 2003 Posts: 148 No chance of a update to 2.0.0.3 unless a miricale happens It's a oldish game The code know looks like this code:Function .onInit sysinfo::GetFileVersion "x:\path\to\exe" Pop$0 Push $0 ;input Push "." ;to replace Push "" ;replace with nothing (remove) Call StrReplace Pop$0 IntCmp \$0 2002 +3 0 +3 MessageBox MB_ICONINFORMATION|MB_OK "The Game has not yet been updated to version 2.02." Abort FunctionEnd With the StrReplace script underneath it Hope this is what you meant, it works anyhow thanks again Thanks again Afrow Sunjammer I looked at the code you suggested, thanks, but Afrow's code is fine.
 Winamp Forums A little help would be appriciated