FileExists, Windows XP Pro 64-bit, and a CFG file in System32 - Delphi

This is a discussion on FileExists, Windows XP Pro 64-bit, and a CFG file in System32 - Delphi ; Hi, I created a file "futura.cfg" down in the System32 directory and then created a sample application that i will put up in the attachments group. The sample application simply tries to use FileExists, FindFirst, and even a simple TStringlist.LoadFromFile ...

+ Reply to Thread
Results 1 to 5 of 5

FileExists, Windows XP Pro 64-bit, and a CFG file in System32

  1. Default FileExists, Windows XP Pro 64-bit, and a CFG file in System32

    Hi,

    I created a file "futura.cfg" down in the System32 directory and then
    created a sample application that i will put up in the attachments group.
    The sample application simply tries to use FileExists, FindFirst, and even a
    simple TStringlist.LoadFromFile call but everytime the calls fail saying
    that the file cannot be found. Even though i know it is physically there and
    it can even be found utilizing this simple VBScript;

    dim fso


    set fso = CreateObject("Scripting.FileSystemObject")
    if fso.FileExists("c:\windows\system32\futura.cfg") then
    MsgBox("Found the file")
    end if


    set fso = Nothing


    Has anyone else ran into this problem?


    Thank you,

    Brian



  2. Default Re: FileExists, Windows XP Pro 64-bit, and a CFG file in System32


    "Brian" <bbop1322=AT=hotmail=DOT=com> wrote in message
    news:4798e2f1@newsgroups.borland.com...

    > I created a file "futura.cfg" down in the System32 directory and then
    > created a sample application that i will put up in the attachments group.


    You did not say which version of Delphi is being used, though. The
    implementation of FileExists() changed after D6. So if you are using an
    older IDE, you may be hitting a known bug in that version where it can
    return False even for files that actually exist. You did not say what the
    actual results of your test at each step actually are when you run it.

    You are also making use of ChDir(), which you should not be doing at all.

    > The sample application simply tries to use FileExists, FindFirst, and
    > even a simple TStringlist.LoadFromFile call but everytime the calls fail
    > saying that the file cannot be found. Even though i know it is physically
    > there and it can even be found utilizing this simple VBScript;


    One thing I see is that you are using of ChDir(). You should not be using
    that at all. Do your test results change if you get rid of it?


    Gambit



  3. Default Re: FileExists, Windows XP Pro 64-bit, and a CFG file in System32

    Hi Remy,

    The version of Delphi is 7.

    I figured out what the problem is sort of. It has more to do with the
    underlying architecture of the XP 64-bit OS. I don't really understand it
    enough though to explain. It is my belief that the 64-bit OS is making use
    of Distributed File System technology and that the OS can interpret the
    file's existence within a certain folder as being in another one. It's
    confusing though because a search using Windows Search yields different
    results then executing an attrib statement through a command window.

    We noticed something really odd when i expanded the sample application to do
    a search through system32 directory using FindFirst, FindNext, and FindClose
    for all files beginning with an "F" and outputting the filenames to a
    listbox. At that point i noticed a number of files that when viewing a
    Windows Explorer window were not really there even though the code was
    reporting they were. This test is what leads me to believe that the DFS
    technology is in use.

    My team has decided to remove the required file to the root Windows
    directory to avoid the confusion between the different system diretories.
    Off the cuff that seems to be the direction that will wok for us.


    BTW, here's a link that we found that kind of sorted it out for us;
    http://searchwincomputing.techtarget...204121,00.html

    Thanks For Your Time,

    Brian



  4. Default Re: FileExists, Windows XP Pro 64-bit, and a CFG file in System32


    "Brian" <bbop1322=AT=hotmail=DOT=com> wrote in message
    news:4799d597$1@newsgroups.borland.com...

    > My team has decided to remove the required file to the root
    > Windows directory to avoid the confusion between the
    > different system diretories.


    That is a huge mistake. Applications are not allowed to store files there,
    or anywhere inside the %WINDIR% hierarchy, for that matter. You are
    supposed to be storing your config files in the CSIDL_APPDATA,
    CSIDL_LOCAL_APPDATA, or CSIDL_COMMON_APPDATA folders instead, depending on
    your needs. Use SHGetSpecialFolderLocation() and related functions to get
    those paths, as they are configurable on a per-machine, per-OS-version
    basis.


    Gambit



  5. Default Re: FileExists, Windows XP Pro 64-bit, and a CFG file in System32

    Remy Lebeau (TeamB) wrote:
    > That is a huge mistake. Applications are not allowed to store files there,
    > or anywhere inside the %WINDIR% hierarchy, for that matter. You are
    > supposed to be storing your config files in the CSIDL_APPDATA,
    > CSIDL_LOCAL_APPDATA, or CSIDL_COMMON_APPDATA folders instead, depending on
    > your needs. Use SHGetSpecialFolderLocation() and related functions to get
    > those paths, as they are configurable on a per-machine, per-OS-version
    > basis.

    Just a shot in the dark. Could the OP's problem have to do with Vista virtualization?
    Mike

+ Reply to Thread