Community
    • Login

    Bitness from NppExec

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 757 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Michael VincentM Offline
      Michael Vincent
      last edited by

      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?

      dinkumoilD 1 Reply Last reply Reply Quote 1
      • dinkumoilD Offline
        dinkumoil @Michael Vincent
        last edited by dinkumoil

        @Michael-Vincent

        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 ProgramFiles variable. 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 no ProgramFiles(x86) variable.

        Thus, the detection path would be:

        1. Check if there is ProgramFiles(x86) variable : No -> 32 bit, finish
        2. Check if ProgramFiles(x86) is equal to ProgramFiles : 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’s SET command.

        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)
        
        1 Reply Last reply Reply Quote 5
        • Michael VincentM Offline
          Michael Vincent
          last edited by

          @dinkumoil : Works great!

          1 Reply Last reply Reply Quote 1

          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
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors