TURBO PASCAL |
Новости
|
53: How can one hide (or unhide) a directory using a TP program?A: Here is the code using interrupt programming. Incidentally, since MS-DOS 5.0 the attrib command can be used to hide and unhide directories. (* Hide a directory. Before using it would be prudent to check that the directory exists, and that it is a directory. With a contribution from Jan Nielsen jak@hdc.hha.dk Based on information from Duncan (1986), p. 410 *) procedure HIDE (dirname : string); var regs : registers; begin FillChar (regs, SizeOf(regs), 0); { standard precaution } dirname := dirname + #0; { requires ASCII strings } regs.ah := $43; { function } regs.al := $01; { subfunction } regs.ds := Seg(dirname[1]); { point to the name } regs.dx := Ofs(dirname[1]); regs.cx := 2; { set bit 1 on } { to unhide set regs.cx := 0 } Intr ($21, regs); { call the interrupt } if regs.Flags and FCarry <> 0 then { were we successful } writeln ('Failed to hide'); end; (* hide *) A2: An alternative method by Dr. Abimbola Olowofoyeku laa12@seq1.keele.ac.uk. No paths. procedure HIDE (dirname : string); var FileInfo : searchRec; f : file; begin FindFirst (dirname, Directory, FileInfo); while DosError = 0 do begin assign (f, FileInfo.Name); SetFAttr (f, Hidden); FindNext (FileInfo); end; end; (* hide *) {} procedure UNHIDE (dirname : string); var FileInfo : searchRec; f : file; begin FindFirst (dirname, AnyFile, FileInfo); while DosError = 0 do begin assign (f, FileInfo.Name); SetFAttr (f, Archive); FindNext (FileInfo); end; end; (* unhide *) |
(с)Все права защищены По всем интересующим вопросам прошу писать на электронный адрес |