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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Attributes

Status
Not open for further replies.

roboz

MIS
Mar 25, 1999
8
AU
Is there a way of toggling the file Read-only and Hidden attributes from within the software using Borland C++ Builder? Thanks
 
roboz,

[tab]Check out access and chmod in io.h. access allows you to determine the file attributes while chmod allows you to change them.

 
use 3 checkboxes and an edit box on a form plus get and set buttons.

void __fastcall TForm1::GetAttrClick(TObject *Sender)
{
int val;
val = FileGetAttr(Edit1->Text);
if (val & faReadOnly)
rCheck->Checked = true;
else rCheck->Checked = false;
if (val & faHidden)
hCheck->Checked = true;
else hCheck->Checked = false;
if (val & faSysFile)
sCheck->Checked = true;
else sCheck->Checked = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SetAttrClick(TObject *Sender)
{
int val= 0;
if(rCheck->Checked) val = val + 1;
if(hCheck->Checked) val = val + 2;
if(sCheck->Checked) val = val + 4;
FileSetAttr(Edit1->Text,val);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top