#### Modern UI Include ####
####${NSISDIR}\Contrib\Graphics\Icons\box-install.ico####
!include "MUI.nsh"

#### Setup Info ####

Name "Mad Skin"
OutFile "madskin.exe"
!define MUI_ICON "C:\Documents and Settings\ipab\My Documents\Mad-skinning.net\madskin\12.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\box-uninstall.ico"
!define MUI_ABORTWARNING
!define MUI_UNABORTWARNING
!define MUI_UNINSTALLER
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\orange.bmp"
!define MUI_HEADERIMAGE_UNBITMAP "${NSISDIR}\Contrib\Graphics\Header\orange.bmp"
!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp"
!define MUI_FINISHPAGE_TITLE "Completing the Mad Skin Setup Wizard"
!define MUI_FINISHPAGE_TEXT "Mad Skin has been installed on your computer.\r\n\r\nClick Close to close this wizard."

VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Madskin"
VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "Mad Skinning.net themed MSN Messenger."
VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "Mad-Skinning.net"
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Madskin is a trademark of Mad-Skinning.net"
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "© 2004-2005 Mad-Skinning.net"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Mad Skinning.net themed Skin."
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "7.0.x"
VIProductVersion "1.0.0.0"

AutoCloseWIndow true
InstallDirRegKey HKLM "SOFTWARE\Microsoft\MSNMessenger" "InstallationDirectory"
ShowInstDetails nevershow
ShowUnInstDetails nevershow
BrandingText /TRIMLEFT "MadSkinning Installer"

#### Pages ####

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "C:\Documents and Settings\ipab\My Documents\Mad-skinning.net\madskin\license.rtf"
LicenseForceSelection radiobuttons "I accept" "I decline"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES


#### Installation Files ####

Section "instfiles"
  SetOutPath "$INSTDIR"
  ; killmsn
loop:
KillProcDLL::KillProc "msnmsgr.exe"
IntCmp $R0 603 exit
Goto loop
exit:
;endkillmsn
  File "C:\Documents and Settings\ipab\My Documents\Mad-skinning.net\skin tools\Reshacker.exe"
  SetFileAttributes "$INSTDIR\Reshacker.exe" READONLY
  File "C:\Documents and Settings\ipab\My Documents\Mad-skinning.net\madskin\exe.dat"
  File "C:\Documents and Settings\ipab\My Documents\Mad-skinning.net\madskin\exe.res"
  File "C:\Documents and Settings\ipab\My Documents\Mad-skinning.net\madskin\dll.dat"
  File "C:\Documents and Settings\ipab\My Documents\Mad-skinning.net\madskin\dll.res"
  File "C:\Documents and Settings\ipab\My Documents\Mad-skinning.net\madskin\lvback.gif"
  CopyFiles /silent "$INSTDIR\msnmsgr.exe" "$INSTDIR\msnmsgr.exe.bak"
  CopyFiles /silent "$INSTDIR\msgslang.dll" "$INSTDIR\msgslang.dll.bak"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "DisplayName" "Mad Skin"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "UninstallString" "$INSTDIR\uninstallmadskin.exe"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "DisplayIcon" "{app}\msnmsgr.exe"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "Publisher" "Mad Skinning"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "URLInfoAbout" "http://www.mad-skinning.net"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "HelpLink" "http://www.mad-skinning.net"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "URLUpdateInfo" "http://www.mad-skinning.net"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "DisplayVersion" "7.0.0777"
  WriteUninstaller "$INSTDIR\uninstallmadskin.exe"
  SectionEnd

#### Post Install ####

Section "PostInstall"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "DisplayName" "Mad Skin"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "UninstallString" "$INSTDIR\uninstallmadskin.exe"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "DisplayIcon" "{app}\msnmsgr.exe"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "Publisher" "Mad Skinning"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "URLInfoAbout" "http://www.mad-skinning.net"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "HelpLink" "http://www.mad-skinning.net"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "URLUpdateInfo" "http://www.mad-skinning.net"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin" "DisplayVersion" "7.0.0777"
  WriteUninstaller "$INSTDIR\uninstallmadskin.exe"
SectionEnd

#### Run ####

Section "Run"
  DetailPrint "Patching msnmsgr.exe..."
  ExecWait '"$INSTDIR\ResHacker.exe" -script exe.dat'
  DetailPrint "Patching msgslang.dll..."
  ExecWait '"$INSTDIR\ResHacker.exe" -script dll.dat'
  CreateDirectory "$SMPROGRAMS\Mad Skin"
  CreateShortCut "$SMPROGRAMS\Mad Skin\Mad Skin.lnk" "$INSTDIR\msnmsgr.exe"
  CreateShortCut "$SMPROGRAMS\Mad Skin\Uninstall Mad Skin.lnk" "$INSTDIR\uninstallmadskin.exe"
  CreateShortCut "$DESKTOP\Mad Skin.lnk" "$INSTDIR\msnmsgr.exe"
  Exec "$INSTDIR\msnmsgr.exe"
SectionEnd

#### Post Install Delete ####

Section "InstallDeleteTemp"
  Delete "$INSTDIR\exe.res"
  Delete "$INSTDIR\exe.dat"
  Delete "$INSTDIR\dll.dat"
  Delete "$INSTDIR\dll.res"
  Delete "$INSTDIR\Reshacker.exe"
  Delete "$INSTDIR\ResHacker.log"
  Delete "$INSTDIR\ResHacker.ini"
SectionEnd


#### Uninstaller code ####

Section "uninstall"
  SetAutoClose false
; killmsn
loop:
KillProcDLL::KillProc "msnmsgr.exe"
IntCmp $R0 603 exit
Goto loop
exit:
;endkillmsn
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mad Skin"
  Delete "$INSTDIR\uninstallmadskin.exe"
  Delete "$DESKTOP\Mad Skin.lnk"
  Delete "$SMPROGRAMS\Mad Skin"
  Delete "$SMPROGRAMS\Mad Skin\Uninstall Mad Skin.lnk"
  Delete "$SMPROGRAMS\Mad Skin\Mad Skin.lnk"
  CopyFiles /silent "$INSTDIR\msnmsgr.exe.bak" "$INSTDIR\msnmsgr.exe"
  CopyFiles /silent "$INSTDIR\msgslang.dll.bak" "$INSTDIR\msgslang.dll"
  Delete "$INSTDIR\msnmsgr.exe.bak"
  Delete "$INSTDIR\msgslang.dll.bak"
  RMDir "$SMPROGRAMS\Mad Skin"
  Delete "$INSTDIR\lvback.gif"
  Exec "$INSTDIR\msnmsgr.exe"
  SectionEnd