From 70ccef9cbc2638c9e8f2f2a544c34d0021d969c6 Mon Sep 17 00:00:00 2001 From: wizou Date: Wed, 21 Apr 2010 08:55:35 +0000 Subject: [PATCH] Unicode: Fixed some scripts git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6068 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/System/System.nsh | 44 +++++++++++++++++++-------------------- Contrib/System/System.nsi | 7 ++++--- Docs/src/usefulinfos.but | 4 ++-- Examples/makensis.nsi | 27 ++++++++++++------------ Include/FileFunc.nsh | 5 +++-- Include/StrFunc.nsh | 2 ++ Source/Tests/winver.nsi | 4 ++-- 7 files changed, 49 insertions(+), 44 deletions(-) diff --git a/Contrib/System/System.nsh b/Contrib/System/System.nsh index 2fb789c1..7add36a9 100644 --- a/Contrib/System/System.nsh +++ b/Contrib/System/System.nsh @@ -15,46 +15,46 @@ !define sysWNDPROC "(i.s, i.s, i.s, i.s) iss" ; LRESULT DefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); -!define sysDefWindowProc "user32::DefWindowProcA(i, i, i, i) i" +!define sysDefWindowProc "user32::DefWindowProc(i, i, i, i) i" -!define sysMessageBox "user32::MessageBoxA(i, t, t, i) i" +!define sysMessageBox "user32::MessageBox(i, t, t, i) i" !define sysMessageBeep "user32::MessageBeep(i) i" -!define sysMessageBoxIndirect 'user32::MessageBoxIndirectA(i) i' +!define sysMessageBoxIndirect 'user32::MessageBoxIndirect(i) i' ; HMODULE GetModuleHandle(LPCTSTR lpModuleName); -!define sysGetModuleHandle "kernel32::GetModuleHandleA(t) i" +!define sysGetModuleHandle "kernel32::GetModuleHandle(t) i" ; HMODULE LoadLibrary(LPCTSTR lpFileName); -!define sysLoadLibrary "kernel32::LoadLibraryA(t) i" +!define sysLoadLibrary "kernel32::LoadLibrary(t) i" ; BOOL FreeLibrary(HMODULE hModule); !define sysFreeLibrary "kernel32::FreeLibrary(i) i" ; HCURSOR LoadCursor(HINSTANCE hInstance, LPCTSTR lpCursorName); -!define sysLoadCursor "user32::LoadCursorA(i, t) i" +!define sysLoadCursor "user32::LoadCursor(i, t) i" ; ATOM RegisterClass(CONST WNDCLASS *lpWndClass); -!define sysRegisterClass "user32::RegisterClassA(i) i" +!define sysRegisterClass "user32::RegisterClass(i) i" ; HANDLE LoadImage(HINSTANCE hinst, LPCTSTR lpszName, UINT uType, ; int cxDesired, int cyDesired, UINT fuLoad); -!define sysLoadImage "user32::LoadImageA(i, t, i, i, i, i) i" +!define sysLoadImage "user32::LoadImage(i, t, i, i, i, i) i" ; BOOL PlaySound(LPCSTR pszSound, HMODULE hmod, DWORD fdwSound); -!define sysPlaySound "winmm.dll::PlaySoundA(t, i, i) i" +!define sysPlaySound "winmm.dll::PlaySound(t, i, i) i" ; HWND CreateWindowEx(DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, ; DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, ; HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam); -!define sysCreateWindowEx "user32::CreateWindowExA(i, t, t, i, i, i, i, i, i, i, i, i) i" +!define sysCreateWindowEx "user32::CreateWindowEx(i, t, t, i, i, i, i, i, i, i, i, i) i" ; BOOL IsWindow(HWND hWnd); !define sysIsWindow "user32::IsWindow(i) i" ; LONG SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong); -!define sysSetWindowLong "user32::SetWindowLongA(i, i, i) i" +!define sysSetWindowLong "user32::SetWindowLong(i, i, i) i" ; BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags); !define sysSetWindowPos "user32::SetWindowPos(i, i, i, i, i, i, i) i" @@ -69,16 +69,16 @@ !define sysGetClientRect "user32::GetClientRect(i, i) i" ; BOOL GetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax); -!define sysGetMessage "user32::GetMessageA(i, i, i, i) i" +!define sysGetMessage "user32::GetMessage(i, i, i, i) i" ; LRESULT DispatchMessage(CONST MSG *lpmsg); -!define sysDispatchMessage "user32::DispatchMessageA(i) i" +!define sysDispatchMessage "user32::DispatchMessage(i) i" ; BOOL DeleteObject(HGDIOBJ hObject); !define sysDeleteObject "gdi32::DeleteObject(i) i" ; int GetObject(HGDIOBJ hgdiobj, int cbBuffer, LPVOID lpvObject); -!define sysGetObject "gdi32::GetObjectA(i, i, i) i" +!define sysGetObject "gdi32::GetObject(i, i, i) i" ; HGDIOBJ SelectObject(HDC hdc, HGDIOBJ hgdiobj); !define sysSelectObject "gdi32::SelectObject(i, i) i" @@ -95,7 +95,7 @@ ; proposed by abgandar ; int AddFontResource(LPCTSTR lpszFilename); -!define sysAddFontResource "gdi32::AddFontResourceA(t) i" +!define sysAddFontResource "gdi32::AddFontResource(t) i" ; HDC BeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint); !define sysBeginPaint "user32::BeginPaint(i, i) i" @@ -104,21 +104,21 @@ !define sysEndPaint "user32::EndPaint(i, i) i" ; BOOL SystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni); -!define sysSystemParametersInfo "user32::SystemParametersInfoA(i, i, i, i) i" +!define sysSystemParametersInfo "user32::SystemParametersInfo(i, i, i, i) i" ; UINT_PTR SetTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc); !define sysSetTimer "user32::SetTimer(i, i, i, k) i" ; DWORD GetLogicalDriveStrings(DWORD nBufferLength, LPTSTR LpBuffer); -!define sysGetLogicalDriveStrings 'kernel32::GetLogicalDriveStringsA(i, i) i' +!define sysGetLogicalDriveStrings 'kernel32::GetLogicalDriveStrings(i, i) i' -!define sysGetDiskFreeSpaceEx 'kernel32::GetDiskFreeSpaceExA(t, *l, *l, *l) i' +!define sysGetDiskFreeSpaceEx 'kernel32::GetDiskFreeSpaceEx(t, *l, *l, *l) i' ; UINT GetDriveType(LPCTSTR lpRootPathName); -!define sysGetDriveType 'kernel32::GetDriveTypeA(t) i' +!define sysGetDriveType 'kernel32::GetDriveType(t) i' ; HANDLE FindFirstFile(LPCTSTR lpFileName,LPWIN32_FIND_DATA lpFindFileData); -!define sysFindFirstFile 'kernel32::FindFirstFileA(t, i) i' +!define sysFindFirstFile 'kernel32::FindFirstFile(t, i) i' ; BOOL FindClose(HANDLE hFindFile); !define sysFindClose 'kernel32::FindClose(i) i' @@ -136,10 +136,10 @@ ; LPSYSTEMTIME lpUniversalTime, LPSYSTEMTIME lpLocalTime); !define sysSystemTimeToTzSpecificLocalTime 'kernel32::SystemTimeToTzSpecificLocalTime(i, i, i) i' -!define syslstrlen 'kernel32::lstrlenA(t) i' +!define syslstrlen 'kernel32::lstrlen(t) i' ; int wsprintf(LPTSTR lpOut, LPCTSTR lpFmt, ...); -!define syswsprintf "user32::wsprintfA(t, t) i ? c" +!define syswsprintf "user32::wsprintf(t, t) i ? c" ; ------------- Structures -------------- diff --git a/Contrib/System/System.nsi b/Contrib/System/System.nsi index 66e08a21..ef70cdc9 100644 --- a/Contrib/System/System.nsi +++ b/Contrib/System/System.nsi @@ -32,7 +32,7 @@ Section "ThisNameIsIgnoredSoWhyBother?" StrCpy $7 ' Disk, Size, Free, Free for user:$\n$\n' ; Memory for paths - System::Alloc 1024 + System::StrAlloc 1024 Pop $1 ; Get drives System::Call '${sysGetLogicalDriveStrings}(1024, r1)' @@ -59,8 +59,9 @@ enumok: enumnext: ; Next drive path + IntOp $2 $2 * ${NSIS_CHAR_SIZE} IntOp $1 $1 + $2 - IntOp $1 $1 + 1 + IntOp $1 $1 + ${NSIS_CHAR_SIZE} goto enumok enumex: ; End of drives or user cancel ; Free memory for paths @@ -72,7 +73,7 @@ enumex: ; End of drives or user cancel ; ----- Sample 3 ----- Direct proc defenition ----- ; Direct specification demo - System::Call 'user32::MessageBoxA(i $HWNDPARENT, t "Just direct MessageBoxA specification demo ;)", t "System Example 3", i ${MB_OK}) i.s' + System::Call 'user32::MessageBox(i $HWNDPARENT, t "Just direct MessageBox specification demo ;)", t "System Example 3", i ${MB_OK}) i.s' Pop $0 ; ----- Sample 4 ----- Int64, mixed definition demo ----- diff --git a/Docs/src/usefulinfos.but b/Docs/src/usefulinfos.but index af018fe2..da5ea816 100644 --- a/Docs/src/usefulinfos.but +++ b/Docs/src/usefulinfos.but @@ -231,13 +231,13 @@ Here is the function: \c FileOpen $5 $5 "w" \c StrCmp $5 0 error \c SendMessage $0 ${LVM_GETITEMCOUNT} 0 0 $6 -\c System::Alloc ${NSIS_MAX_STRLEN} +\c System::StrAlloc ${NSIS_MAX_STRLEN} \c Pop $3 \c StrCpy $2 0 \c System::Call "*(i, i, i, i, i, i, i, i, i) i \ \c (0, 0, 0, 0, 0, r3, ${NSIS_MAX_STRLEN}) .r1" \c loop: StrCmp $2 $6 done -\c System::Call "User32::SendMessageA(i, i, i, i) i \ +\c System::Call "User32::SendMessage(i, i, i, i) i \ \c ($0, ${LVM_GETITEMTEXT}, $2, r1)" \c System::Call "*$3(&t${NSIS_MAX_STRLEN} .r4)" \c FileWrite $5 "$4$\r$\n" diff --git a/Examples/makensis.nsi b/Examples/makensis.nsi index b673dc5e..dc4e7f7d 100644 --- a/Examples/makensis.nsi +++ b/Examples/makensis.nsi @@ -280,6 +280,7 @@ ${MementoSection} "Script Examples" SecExample File ..\Examples\Plugin\nsis\pluginapi.h File ..\Examples\Plugin\nsis\pluginapi.lib File ..\Examples\Plugin\nsis\api.h + File ..\Examples\Plugin\nsis\nsis_tchar.h ${MementoSectionEnd} @@ -793,19 +794,19 @@ Section -post WriteRegDword HKLM "Software\NSIS" "VersionBuild" "${VER_BUILD}" !endif - WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" "UninstallString" '"$INSTDIR\uninst-nsis.exe"' - WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" "InstallLocation" "$INSTDIR" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" "DisplayName" "Nullsoft Install System" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" "DisplayIcon" "$INSTDIR\NSIS.exe,0" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" "DisplayVersion" "${VERSION}" + WriteRegExpandStr HKLM "${MEMENTO_REGISTRY_KEY}" "UninstallString" '"$INSTDIR\uninst-nsis.exe"' + WriteRegExpandStr HKLM "${MEMENTO_REGISTRY_KEY}" "InstallLocation" "$INSTDIR" + WriteRegStr HKLM "${MEMENTO_REGISTRY_KEY}" "DisplayName" "Nullsoft Install System" + WriteRegStr HKLM "${MEMENTO_REGISTRY_KEY}" "DisplayIcon" "$INSTDIR\NSIS.exe,0" + WriteRegStr HKLM "${MEMENTO_REGISTRY_KEY}" "DisplayVersion" "${VERSION}" !ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" "VersionMajor" "${VER_MAJOR}" - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" "VersionMinor" "${VER_MINOR}.${VER_REVISION}" + WriteRegDWORD HKLM "${MEMENTO_REGISTRY_KEY}" "VersionMajor" "${VER_MAJOR}" + WriteRegDWORD HKLM "${MEMENTO_REGISTRY_KEY}" "VersionMinor" "${VER_MINOR}.${VER_REVISION}" !endif - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" "URLInfoAbout" "http://nsis.sourceforge.net/" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" "HelpLink" "http://nsis.sourceforge.net/Support" - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" "NoModify" "1" - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" "NoRepair" "1" + WriteRegStr HKLM "${MEMENTO_REGISTRY_KEY}" "URLInfoAbout" "http://nsis.sourceforge.net/" + WriteRegStr HKLM "${MEMENTO_REGISTRY_KEY}" "HelpLink" "http://nsis.sourceforge.net/Support" + WriteRegDWORD HKLM "${MEMENTO_REGISTRY_KEY}" "NoModify" "1" + WriteRegDWORD HKLM "${MEMENTO_REGISTRY_KEY}" "NoRepair" "1" WriteUninstaller $INSTDIR\uninst-nsis.exe @@ -949,7 +950,7 @@ Function PageLeaveReinstall StrCmp $R1 "1" reinst_done reinst_uninstall reinst_uninstall: - ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" "UninstallString" + ReadRegStr $R1 HKLM "${MEMENTO_REGISTRY_KEY}" "UninstallString" ;Run uninstaller HideWindow @@ -1021,7 +1022,7 @@ Section Uninstall System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)' - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" + DeleteRegKey HKLM "${MEMENTO_REGISTRY_KEY}" DeleteRegKey HKLM "Software\NSIS" SetDetailsPrint textonly diff --git a/Include/FileFunc.nsh b/Include/FileFunc.nsh index 8bd86433..e1963770 100644 --- a/Include/FileFunc.nsh +++ b/Include/FileFunc.nsh @@ -968,7 +968,7 @@ RefreshShellIcons Push $8 Push $9 - System::Alloc 1024 + System::StrAlloc 1024 Pop $2 System::Call 'kernel32::GetLogicalDriveStrings(i,i) i(1024, r2)' @@ -1053,8 +1053,9 @@ RefreshShellIcons StrCmp $9 'StopGetDrives' FileFunc_GetDrives_enumex FileFunc_GetDrives_enumnext: + IntOp $4 $4 * ${NSIS_CHAR_SIZE} IntOp $3 $3 + $4 - IntOp $3 $3 + 1 + IntOp $3 $3 + ${NSIS_CHAR_SIZE} goto FileFunc_GetDrives_enumok FileFunc_GetDrives_enumex: diff --git a/Include/StrFunc.nsh b/Include/StrFunc.nsh index 1b0cb18c..64f91c11 100644 --- a/Include/StrFunc.nsh +++ b/Include/StrFunc.nsh @@ -405,6 +405,7 @@ o-----------------------------------------------------------------------------o ;Step 2: Allocate global heap StrLen $2 $0 IntOp $2 $2 + 1 + IntOp $2 $2 * ${NSIS_CHAR_SIZE} System::Call 'kernel32::GlobalAlloc(i 2, i r2) i.r2' ;Step 3: Lock the handle @@ -449,6 +450,7 @@ o-----------------------------------------------------------------------------o ;Step 5: Allocate global heap StrLen $2 $0 IntOp $2 $2 + 1 + IntOp $2 $2 * ${NSIS_CHAR_SIZE} System::Call 'kernel32::GlobalAlloc(i 2, i r2) i.r2' ;Step 6: Lock the handle diff --git a/Source/Tests/winver.nsi b/Source/Tests/winver.nsi index 5d8c8a68..a5b21e50 100644 --- a/Source/Tests/winver.nsi +++ b/Source/Tests/winver.nsi @@ -108,7 +108,7 @@ Var OSVERSIONINFOEX_INIT !macro __WinVer_Call_GetVersionEx STRUCT_SIZE - !if ${STRUCT_SIZE} == ${OSVERSIONINFOA_SIZE} + !if ${STRUCT_SIZE} == ${OSVERSIONINFO_SIZE} StrCpy $3 $OSVERSIONINFO_RES Push $OSVERSIONINFO_CSD @@ -116,7 +116,7 @@ Var OSVERSIONINFOEX_INIT !endif - !if ${STRUCT_SIZE} == ${OSVERSIONINFOEXA_SIZE} + !if ${STRUCT_SIZE} == ${OSVERSIONINFOEX_SIZE} StrCpy $3 $OSVERSIONINFOEX_RES Push $OSVERSIONINFOEX_CSD