GetPrivateProfileString failed

This is a discussion on GetPrivateProfileString failed within the Windows Programming forums, part of the Platform Specific Boards category; I have a code that was working for years without problems It was reading some ini-file using GetPrivateProfileString and GetPrivateProfileInt ...

  1. #1
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484

    GetPrivateProfileString failed

    I have a code that was working for years without problems
    It was reading some ini-file using
    GetPrivateProfileString and GetPrivateProfileInt functions

    Now - I have to change the place of the ini-file
    so instead of "./setup.ini"

    function now receives a new location like "../WorkDir/ff44198ee855e6aaa8ea845a894e972b/setup.ini"

    the current directory is not changed, and file location is also chacked (I open in the explorer the current dir of the process and add to it the above string - as a result the file is opened in textpad)

    But the GetPrivateProfileXXX functions all fail returning the default values provided instead of stored in the ini-file

    I was trying to apply GetShortPath function before passing the path to GetPrivateProfileXXX

    path was transformed correctly but result has not changed

    Even stranger - is was working with this paths once, but after last compilation I could not make it work, and I could not retreive any reasonable error code...

    Rebuild all does nnot helps.

    Have somebody any idea what could be a source of the problem?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,662
    I would first rule out a ill-formed ini file as the root of the problem. Try an extremely simple ini file and see if you stop getting default values.

    gg

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    ini file was not changed from the working version
    what was changed and may affect this strange behavior (but i do not understand really how - I will check my guess when I get to work) - I have added some assert in a part of the code that does not intersect in any way with the code parsing ini and it does not executed - application exitted before getting to the code where assert is located
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Ok just to close the issue.
    The problem is solved.

    And still do not know exactly - what is the sorce of the problem.

    One of the key changes:
    The current process dir was set using mapped drive like
    folder
    e:\views was shared and mapped to l: drive
    and current folder was set to l:\debug\bin

    after changing the current folder to
    e:\views\debug\bin problem does not occure anymore.

    I do not know why fopen works fine with the previos settings, while GetPrivateProfileString fails sighlently.

    (As a side note - C# application with the same settings of the current folder behaves even more strangely - starts ok from e: and give a security exception when i try to start the same exe using l: drive)
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Find Injected DLLs In A Process?
    By pobri19 in forum Windows Programming
    Replies: 35
    Last Post: 02-06-2010, 08:53 AM
  2. addrinfo Structure Not Working
    By pobri19 in forum Networking/Device Communication
    Replies: 9
    Last Post: 10-22-2008, 10:07 AM
  3. C++ text file
    By statquos in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2008, 01:42 PM
  4. gethostbyaddr() reverse lookups failing (???)
    By Uncle Rico in forum C Programming
    Replies: 9
    Last Post: 08-19-2005, 09:22 AM
  5. Ask about Debug Assert Failed
    By ooosawaddee3 in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2002, 11:07 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21