ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
1149
1149
EMPFEHLEN
-
20.02.04 23:13 #1
- Registriert seit
- Aug 2003
- Beiträge
- 104
hi Leute hab folgendes Problem. Ich hab mir mit dem bcbuilder 5 ein programm gemacht, welches die Attribute von Dateien ändert. Ich hab nur das Problem dass ich die Bitflags nicht richtig setzen kann(weis nicht wie) um die Attribute zu löschen. Aktivieren ****zt gut aber ich schaff es nicht die Attribute zu deaktivieren.
Bitte hilfe. Danke
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include <dir.h> #include "dateiattribute.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; int disk; char *help = new char [255]; WIN32_FIND_DATA fData; char buf[256]; HANDLE hSearch; BOOL MoreFiles = FALSE; char cselect[255]; char cselected[255]; DWORD attrib; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { Application->MessageBoxA("Dieses Prog kann Dateiattribute ändern","Hinweis",MB_OK | MB_ICONEXCLAMATION); for (int disk = 0;disk < 10;disk++) { setdisk(disk); if (disk == getdisk()) { *help=char(disk + 97); help[1] = ':'; ComboBox1->Items->Add(help); } } } //--------------------------------------------------------------------------- //hier werden die Laufwerke eingelesen void __fastcall TForm1::ComboBox1Change(TObject *Sender) { char *Buffer = new char[20]; ListBox1->Clear(); ListBox2->Clear(); ComboBox1->GetTextBuf(Buffer,255); strcat(Buffer,"\\*.*"); hSearch=FindFirstFile(Buffer,&fData); do { if(fData.dwFileAttributes &= FILE_ATTRIBUTE_DIRECTORY) //die Ordner werden in Listbox1 aufgelistet { ListBox1->Items->Add((fData.cFileName)); } else { ListBox2->Items->Add(fData.cFileName); //die Dateien werden in ListBox2 aufgelistet } MoreFiles = FindNextFile(hSearch,&fData); } while(MoreFiles); } //--------------------------------------------------------------------------- void __fastcall TForm1::ListBox1DblClick(TObject *Sender) { char *buf = new char[255]; HANDLE iSearch; for (int i = 0;i < ListBox1->Items->Count; i++) { if (ListBox1->Selected[i]) { ComboBox1->GetTextBuf(buf,255); strcpy(cselected,buf); strcat(cselected,"\\"); strcpy(cselect,ListBox1->Items->Strings[ListBox1->ItemIndex].c_str()); strcat(cselected,cselect); strcat(cselected,"\\*.*"); ListBox1->Items->Add(cselected); } }//nicht für das problem wichtig - ermittlung der dateinamen(laufwerk\verzeichnis\datei) ListBox1->Clear(); ListBox2->Clear(); iSearch=FindFirstFile(cselected,&fData); do { if(fData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { ListBox1->Items->Add((fData.cFileName)); } else { ListBox2->Items->Add(fData.cFileName); } MoreFiles = FindNextFile(iSearch,&fData); } while(MoreFiles); } //--------------------------------------------------------------------------- //Attribute auslesen und bearbeiten void __fastcall TForm1::ListBox2Click(TObject *Sender) { hide -> State = cbUnchecked; Protected -> State = cbUnchecked; Archived -> State = cbUnchecked; System -> State = cbUnchecked; for (int i = 0;i < ListBox1->Items->Count; i++) { if (ListBox2->Selected[i]) { ComboBox1->GetTextBuf(buf,255); strcpy(cselected,buf); strcat(cselected,"\\"); strcpy(cselect,ListBox2->Items->Strings[ListBox2->ItemIndex].c_str()); strcat(cselected,cselect); } } attrib = GetFileAttributes(cselected); if(attrib & FILE_ATTRIBUTE_HIDDEN) hide->State = cbChecked; if(attrib & FILE_ATTRIBUTE_READONLY) Protected -> State = cbChecked; if(attrib & FILE_ATTRIBUTE_ARCHIVE) Archived -> State = cbChecked; if(attrib & FILE_ATTRIBUTE_SYSTEM) System -> State = cbChecked; } //--------------------------------------------------------------------------- void __fastcall TForm1::attributeClick(TObject *Sender) { DWORD checker1,checker2,checker3,checker4; checker1 = hide->Checked; checker2 = Protected->Checked; checker3 = Archived->Checked; checker4 = System->Checked; attrib = GetFileAttributes(cselected); if(checker2 == TRUE) SetFileAttributes(cselected,attrib |= FILE_ATTRIBUTE_READONLY); else if(checker2 == FALSE) SetFileAttributes(cselected,attrib |= !FILE_ATTRIBUTE_READONLY); attrib = GetFileAttributes(cselected); if(checker1 == TRUE) SetFileAttributes(cselected,attrib |= FILE_ATTRIBUTE_HIDDEN); else if(checker1 == FALSE) SetFileAttributes(cselected,attrib |= !FILE_ATTRIBUTE_HIDDEN); attrib = GetFileAttributes(cselected); if(checker3 == TRUE) SetFileAttributes(cselected,attrib |= FILE_ATTRIBUTE_ARCHIVE); else if(checker3 == FALSE) SetFileAttributes(cselected,attrib |= !FILE_ATTRIBUTE_ARCHIVE); attrib = GetFileAttributes(cselected); if(checker4 == TRUE) SetFileAttributes(cselected,attrib |= FILE_ATTRIBUTE_SYSTEM); else if(checker4 == FALSE) SetFileAttributes(cselected,attrib |= !FILE_ATTRIBUTE_SYSTEM); } //---------------------------------------------------------------------------
ps: ist mit gui hoffe ihr kommts ohne dem foto dazu ausGeändert von Nebuchadnezar (20.02.04 um 23:20 Uhr)
Ähnliche Themen
-
Dateiattribute abfragen
Von thekiller im Forum VisualStudio & MFCAntworten: 6Letzter Beitrag: 06.01.10, 10:49 -
ZIP File und Dateiattribute
Von schindi42 im Forum JavaAntworten: 8Letzter Beitrag: 08.12.09, 22:47 -
Dateiattribute erweitern [Windows]
Von flashray im Forum Coders TalkAntworten: 2Letzter Beitrag: 29.09.09, 08:53 -
Dateiattribute auslesen
Von Tschena im Forum C/C++Antworten: 3Letzter Beitrag: 20.11.06, 19:31 -
Auf Dateiattribute zugreifen (Erstellungsdatum)
Von Immi im Forum JavaAntworten: 2Letzter Beitrag: 11.03.05, 14:40





Zitieren
Login






