Minor optimizations

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7286 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2021-07-27 18:56:42 +00:00
parent a24b5d6f62
commit 50ef1d3369
3 changed files with 9 additions and 7 deletions

View file

@ -57,8 +57,10 @@ int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int
// Try to register the SysLink class
DWORD iccestruct[2] = { 8, 0x8000 }; // ICC_LINK_CLASS (ComCtl32v6)
FARPROC icce = SupportsW95() ? GetSysProcAddr("COMCTL32", "InitCommonControlsEx") : (FARPROC) InitCommonControlsEx;
BOOL succ = ((BOOL(WINAPI*)(const void*))icce)(iccestruct);
BOOL suppw95 = SupportsW95();
FARPROC icce = suppw95 ? GetSysProcAddr("COMCTL32", "InitCommonControlsEx") : (FARPROC) InitCommonControlsEx;
BOOL succ = (!suppw95 || icce) && ((BOOL(WINAPI*)(const void*))icce)(iccestruct);
#if (!defined(_MSC_VER) && !defined(_WIN64)) || (defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_IA64))) // x86 or Itanium
if (!succ && (sizeof(void*) > 4 || LOBYTE(GetVersion()) >= 5)) // Must check the version because older shell32 versions have a incompatible function at the same ordinal
{
FARPROC lwrc = GetSysProcAddr("SHELL32", (LPCSTR) 258); // LinkWindow_RegisterClass
@ -70,6 +72,7 @@ int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int
RegisterClass(&wc); // Superclass the old link window class if SysLink is not available
}
}
#endif
memset(&g_sdata,0,sizeof(NSCRIPTDATA));
memset(&g_resize,0,sizeof(NRESIZEDATA));

View file

@ -164,8 +164,7 @@ int SetArgv(const TCHAR *cmdLine, TCHAR ***argv) {
void SetTitle(HWND hwnd,const TCHAR *substr) {
TCHAR title[64];
if (substr==NULL) wsprintf(title,_T("MakeNSISW"));
else wsprintf(title,_T("MakeNSISW - %s"),substr);
wsprintf(title,substr ? _T("MakeNSISW - %s") : _T("MakeNSISW"),substr);
SetWindowText(hwnd,title);
}
@ -183,7 +182,7 @@ void PlayAppSoundAsync(LPCSTR SoundName, int MBFallback) {
PLAYAPPSOUNDDATA *p = (PLAYAPPSOUNDDATA*) MemAlloc(sizeof(PLAYAPPSOUNDDATA));
if (p) {
p->SoundName = SoundName, p->MBFallback = MBFallback; // Note: The string must be valid until the sound has started because we don't copy it
HANDLE hThread = CreateThread(NULL, 0, PlayAppSoundProc, p, 0, &tid);
HANDLE hThread = CreateThread(NULL, 0, PlayAppSoundProc, p, 0, SupportsW9X() ? &tid : (tid, NULL));
if (hThread) CloseHandle(hThread); else PlayAppSoundProc(p);
}
}

View file

@ -196,9 +196,9 @@ TCHAR *CharPrev(const TCHAR *s, const TCHAR *p) {
}
char *CharNextA(const char *s) {
int l = 0;
int l = 0, mbl;
if (s && *s)
l = max(1, mblen(s, MB_CUR_MAX));
mbl = mblen(s, MB_CUR_MAX), l = max(1, mbl);
return const_cast<char*>(s + l);
}