Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WritePrivateProfileString

Status
Not open for further replies.

Tremorblue

Programmer
Apr 30, 2004
56
GB
Using WritePrivateProfileString to setup and ini file.

It can be used by users or administrator on a PC.

If the administrator uses it first then it locks the file out because of access rights.

If I check for fileExists I could write the file with access rights to all before calling WritePrivateProfileString.

My question if how could I create an empty file and give everyone access rights to use it ?
 
Here is an example of using streams to create a file.
Code:
    UnicodeStream LogFileUniStr = "C:\\Temp\\LogFile.txt";
    // Open streams
    std::wofstream FileOutStrm;
    ParcelCSVStrm.open(LogFileUniStr.c_str(), std::ios::app); // Open file for appending
    if (!LogFileStrm)
    {
        MessageDlg(L"I Cannot open log file for output!", mtError, TMsgDlgButtons() << mbOK, 0);
        FileOutStrm.close();
        return false;
    }
    //FileOutStrm << std::endl; // Not usually necessary
    FileOutStrm.close();
Usually, this creates the empty file. Access privilege are open to everyone in Windows unless you set up the folder differently.


James P. Cottingham
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top