Announcement

Collapse
No announcement yet.

EXE.Path$ + "\\?\"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • EXE.Path$ + "\\?\"

    I have started using EXE.Path$ - I noticed it always starts with \\?\ - Does it do that always? Have any of you given this some thought?

    I am thinking I need to ponder this as some of my code runs in environments where there are domains.


    Code:
    FUNCTION HANDLE_RUNTIME_ERRORS(FUNCTION_NAME AS STRING, ERROR_STRING AS STRING, ERROR_NUMBER AS LONG, OPTIONAL HINT_STRING AS STRING)AS STRING
    
    
    LOCAL FILE_NUMBER AS LONG 
    FILE_NUMBER = FREEFILE
    
    LOCAL FILE_PATH AS STRING :
    FILE_PATH = EXE.PATH$
    
    REPLACE "\\?\" WITH "" IN FILE_PATH
    
    OPEN FILE_PATH + "\ERRORS_RT.TXT" FOR APPEND AS FILE_NUMBER
    PRINT #FILE_NUMBER, DATE$ + " - " + TIME$ + " - " + FUNCTION_NAME + " - " + ERROR_STRING + " - " + FORMAT$(ERROR_NUMBER)
    CLOSE FILE_NUMBER
    
    
    END FUNCTION 



  • #2
    Hi David!

    Mine does not start with that. Mine has this "C:\gbapps\myapp". I'm on a home network.

    Comment


    • #3
      I get a normal path. For me its F:\PowerBasic\
      Code:
      #COMPILER PBWIN
      #COMPILE EXE
      #DIM ALL
      
      FUNCTION PBMAIN () AS LONG
        LOCAL FILE_PATH AS STRING
        FILE_PATH = EXE.PATH$
        ? FILE_PATH
      END FUNCTION
      This is on a domain with drive mapping.

      Comment


      • #4
        At work when I am running a program from a local URL instead of a mapped drive, I will get
        something like "\\93.184.216.34\Test".

        Looks like you may be getting normal return values when running from URLs instead of mapped drives.
        ... .... . ... . . ... ... .... . .. ... .... .. ... .... .. .... ..

        n6jah @ yahoo.com

        Comment


        • #5
          Originally posted by David Clarke View Post
          I have started using EXE.Path$ - I noticed it always starts with \\?\ - Does it do that always? Have any of you given this some thought?

          I am thinking I need to ponder this as some of my code runs in environments where there are domains.
          > REPLACE "\\?" WITH "" IN FILE_PATH

          Danger, Will Robinson!

          You are better off leaving the path string as is. It's a perfectly valid WIn32 pathname

          Are they very long paths? Do you have folder names containing dots?
          If so, you need that form. You will generally only get that form if it is needed.

          Have a good read of:

          https://docs.microsoft.com/en-us/win.../naming-a-file

          Especially the section headed "Win32 File Namespaces"


          "For file I/O, the "\\?" prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system. For example, if the file system supports large paths and file names, you can exceed the MAX_PATH limits that are otherwise enforced by the Windows APIs. For more information about the normal maximum path limitation, see the previous section Maximum Path Length Limitation.

          Because it turns off automatic expansion of the path string, the "\\?" prefix also allows the use of ".." and "." in the path names, which can be useful if you are attempting to perform operations on a file with these otherwise reserved relative path specifiers as part of the fully qualified path.

          Many but not all file I/O APIs support "\\?"; you should look at the reference topic for each API to be sure.

          Note that Unicode APIs should be used to make sure the "\\?" prefix allows you to exceed the MAX_PATH

          Comment


          • #6
            If what EXE.PATH$ is returning is , er, "iffy" you can compare it with what is returned by the API function GetModuleFileName() with the module handle equal to "BYVAL 0&"

            I don't know why you need the EXE path but this is another way to get it.
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              FWIW,
              DIR$ , FILECOPY, KILL, EXE,,,, PATHNAME and PATHSCAN

              all recognise "\\?\C:....." as a valid path
              but OPEN and GETATTR / SETATTR don't

              Bug or is this a feature request?

              Comment


              • #8
                Thanks guys! Very interesting!!

                Comment

                Working...
                X