Archive: Native OS Detection in NSIS


Native OS Detection in NSIS
To some of those who might want this ablity in there NSIS scripts and have a compiler if you want OS Detection you can add this to util.c in the exehead project in the process_strings function i generally place this after the SYSDIR varibale.. but here it is


else if (!strcmp_nstr2(&in,"SYSDIR"))
{
GetSystemDirectory(out,1024);
}
else if (!strcmp_nstr2(&in, "WINOS"))
{
OSVERSIONINFO winfo;
winfo.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(&winfo);
if(winfo.dwPlatformId==VER_PLATFORM_WIN32_NT)
{
lstrcpy(out,"WINNT");
}
else if(winfo.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS)
{
lstrcpy(out, "WIN9X");
}
}


this will just insert the strings WINNT or WIN9X into $WINOS variable and you can do a Simple StrCmp on it for your code.. hope people will like it.

or to save yourself some space in the exe header use


else if (!strcmp_nstr2(&in, "WINOS"))
{
if ((BOOL)(GetVersion() < 0x80000000))
{
lstrcpy(out,"WINNT");
}
else
{
lstrcpy(out, "WIN9X");
}
}