Bitness from NppExec
-
Is there a way to determine the bitness (32 or 64) of Notepad++ from the NppExec plugin? I can get the N++ version:
NPP_SENDMSG NPPM_GETNPPVERSION SET nppmajver ~ int($(MSG_RESULT)/65536) SET nppminver ~ $(MSG_RESULT)%65536 echo $(nppmajver).$(nppminver)But wondering if there’s a way to determine 32 or 64 bit? Obviously getting the bitness of the NppExec plugin itself would work. I was trying a clever math thing with INT but not working.
Any insights?
-
If a 32 bit process runs on a 64 bit OS it has a slightly different set of environment variables than a 64 bit process, they differ e.g. in the value of the
ProgramFiles(x86)environment variable.For a 32 bit process on a 64 bit OS its value is the same like the value of the
ProgramFilesvariable. For a 64 bit process the values of these variables are different. And for a 32 bit process on a 32 bit OS there is noProgramFiles(x86)variable.Thus, the detection path would be:
- Check if there is
ProgramFiles(x86)variable : No -> 32 bit, finish - Check if
ProgramFiles(x86)is equal toProgramFiles: Yes -> 32 bit, No -> 64 bit
Unfortunately it is not possible to use NppExec’s
$(SYS.ProgramFiles(x86))because the parser is not able to deal with the paranthesis in the variable name (testet with NppExec v0.6 RC2). But there is a workaround: parsing the output of the console’sSETcommand.Test the following NppExec script:
npe_console -- m- npp_console disable npe_console -- v+ cmd.exe /c "for /f "tokens=1* delims==" %a in ('set ProgramFiles^(x86^) 2^>NUL') do @echo %b" set local $(CallResult) = $(OUTPUT) npe_console -- v- if "$(CallResult)" == "" then set local $(Bitness) = 32 else if "$(CallResult)" == "$(SYS.ProgramFiles)" then set local $(Bitness) = 32 else set local $(Bitness) = 64 endif endif npp_console enable echo $(Bitness) - Check if there is
-
@dinkumoil : Works great!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login