Results 1 to 5 of 5

Thread: Does WritePrivateProfileString close the file after the write?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Posts
    126

    Does WritePrivateProfileString close the file after the write?

    Likewise, does GetPrivateProfileString do so after a read?

  2. #2
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: Does WritePrivateProfileString close the file after the write?

    Yes, every time you read or write, you have to open and close the file.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Posts
    126

    Re: Does WritePrivateProfileString close the file after the write?

    So neither API actually does the opening or closing?

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Does WritePrivateProfileString close the file after the write?

    The file is opened with no sharing, effectively locking it. Then the entire file is read and parsed or rewritten. Then the file is closed, effectively unlocking it.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Posts
    126

    Re: Does WritePrivateProfileString close the file after the write?

    Quote Originally Posted by dilettante View Post
    The file is opened with no sharing, effectively locking it. Then the entire file is read and parsed or rewritten. Then the file is closed, effectively unlocking it.
    Ahh OK. I have a program where window location and size is corrupted if the program crashes. Other entries in the .ini aren't affected and I write window location on program end or unloading that particular window

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width