Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Invoking Notepad++ from another application using ShellExecEx - issue with 7.6.3

    Help wanted · · · – – – · · ·
    3
    8
    1055
    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.
    • PPsmm
      PPsmm last edited by

      Hello: about 10 years ago I made a little file/text search application that displays a list of matching files in a list when a search completes.

      When you click an item in this list, it launches a user-specified application associated with the type (determined by extension) for the selected file. The Win32 ShellExecuteEx function is used for this purpose.

      I configured the application to use Notepad++ for all .txt files. This has been working without issue for many years.

      However, I recently updated from (I believe) Notepad++ 7.5.8 to version 7.6.3, and ever since, when I invoke Notepad++ from within the application, I see a pair of dialog boxes within Notepad++. The first says

      Create new file
      “z:\home\PPsmm\My” doesn’t exist. Create it?

      When I click “No”, the second box says:

      Cannot open file
      “C:\WINDOWS\system32\Documents\Folder\sub_folder\test.php” cannot be opened:
      Folder “C:\WINDOWS\system32\Documents\Folder\sub_folder\test” doesn’t exist

      There seems to be some issue with long file names here. I haven’t done any desktop development for the best part of a decade, and the (my) application hasn’t been altered during that time. My OS is Windows 10 Pro 17134, and I’m using the 64-bit build of Notepad++ (and had previously for build 7.5.8). Has something changed with Notepad++ in this most recent release that might be causing this issue?

      Thank you

      Meta Chuh 1 Reply Last reply Reply Quote 0
      • Meta Chuh
        Meta Chuh @PPsmm last edited by Meta Chuh

        @PPsmm

        it looks like you are calling a path with a space.

        the first part of the path is z:\home\PPsmm\My
        followed by a [space]
        and continued with Documents\Folder\sub_folder\test.php

        so if i’m correct, the true, full path should be: z:\home\PPsmm\My Documents\Folder\sub_folder\test.php

        in this case you have to wrap your Win32 ShellExecuteEx paths in double quotes (escaped double quotes if necessary).

        instead of: path_to_your\Notepad++.exe path_to_your\file.php
        your command line should be: "path_to_your\Notepad++.exe" "path_to_your\file.php"
        (replace with \\ and/or \" if escaping is needed)

        1 Reply Last reply Reply Quote 1
        • Alan Kilborn
          Alan Kilborn last edited by

          There was a Notepad++ design change between the versions the OP cites that changed how this worked. I believe but am not absolutely certain that it was in 7.5.9 (read a posting on github recently that I can’t find right now). So, OP, please don’t desire the old behavior back and report this as a bug.

          1 Reply Last reply Reply Quote 2
          • PPsmm
            PPsmm last edited by

            Thank you for the replies. I had a quick look on the GitHub “Issues” page, and it seems that someone else has already submitted a note about this, though the details are contained within a PDF file (presumably because that allowed the author to illustrate the details with annotated screenshots).

            https://github.com/notepad-plus-plus/notepad-plus-plus/issues/5329

            Not really sure how to move forward from this. It seems that my application simply passes the complete file path (which does include spaces are Meta Chuh observed) as a LPCSTR to ShellExecEx - probably ShellExecExA, since the application was compiled in an old version of the Delphi development environment.

            Meta Chuh 1 Reply Last reply Reply Quote 1
            • Meta Chuh
              Meta Chuh @PPsmm last edited by Meta Chuh

              @PPsmm

              the user of the issue you are referring to, has a registry entry with missing quotes (") in the shell open command, which is a leftover from an older installation that had this bug.

              currently there is no other known way than to call “notepad++.exe” “%1”, if there is a space in the path.
              the full path, with possible spaces, has to be in quotes, to be passed as a single argv, otherwise every space would trigger the rest to be part of a second, third, etc. argv.

              you will need to recompile your app using your path/file argv (single argv) in escaped quotes, usually written like "\"path to your\\file.php\""

              1 Reply Last reply Reply Quote 2
              • PPsmm
                PPsmm last edited by

                Understood, thanks Meta Chuh. Unfortunately I don’t have access to the development environment any more, but perhaps I’ll have a go at porting it over to Free Pascal / Lazarus at some stage.

                In the meantime, I’ve reverted to 7.5.8

                Meta Chuh 1 Reply Last reply Reply Quote 1
                • Meta Chuh
                  Meta Chuh @PPsmm last edited by Meta Chuh

                  @PPsmm

                  Unfortunately I don’t have access to the development environment any more.

                  understood, and glad you got it working again by reverting to 7.5.8.

                  there might be another workaround, if the path to your notepad++.exe (eg. C:\Program Files (x86)\Notepad++\notepad++.exe) is not hard coded in your old borland tool, and you want to have both worlds, a newest 7.6.3 install and a 7.5.8 “viewer” for your tool:

                  download a portable 7.5.8 version from >>> here <<<,
                  extract it to e.g. C:\PortableApps\npp.7.5.8.bin,
                  and set the C:\PortableApps\npp.7.5.8.bin\notepad++.exe as viewer for your tool.

                  if this path change is possible, you can use this portable 7.5.8 as viewer for your tool, without any need to set argv[1] in quotes, and enjoy all new and future notepad++ features on your default install.

                  if a path change to notepad++ is not possible in your tool, you can also play around with doing it the other way round, use a new portable for yourself, and an old installation for your tool.

                  (all that, of course, only if you want or need anything higher than 7.5.8 ;-) )

                  1 Reply Last reply Reply Quote 3
                  • PPsmm
                    PPsmm last edited by

                    Thanks Meta Chuh, that’s a really clever idea - I’ll definitely give this a try

                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post
                    Copyright © 2014 NodeBB Forums | Contributors