one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
twenty-one
twenty-two
twenty-three
twenty-four
twenty-five
twenty-six
twenty-seven
twenty-eight
twenty-nine
thirty
thirty-one
thirty-two
thirty-three
thirty-four
thirty-five
thirty-six
thirty-seven
thirty-eight
thirty-nine
forty
forty-one
forty-two
forty-three
forty-four
forty-five
forty-six
forty-seven
forty-eight
forty-nine
fifty
fifty-one
fifty-two
fifty-three
fifty-four
fifty-five
fifty-six
fifty-seven
fifty-eight
fifty-nine
sixty
sixty-one
sixty-two
sixty-three
sixty-four
sixty-five
sixty-six
sixty-seven
sixty-eight
sixty-nine
seventy
seventy-one
seventy-two
seventy-three
seventy-four
seventy-five
seventy-six
seventy-seven
seventy-eight
seventy-nine
eighty
eighty-one #ifdef Unicode
#define A "W"
#else
#define A "A"
#endif
[ code ]
const
myMark = 'Written by gnatix' ; //As identification
function GetFileAttributes ( lpFileName: String ) : Cardinal ;
external 'GetFileAttributes{#A}@kernel32.dll stdcall' ;
function SetFileAttributes ( lpFileName: String ; dwFileAttributes: Cardinal ) : Boolean ;
external 'SetFileAttributes{#A}@kernel32.dll stdcall' ;
function LineInFile ( sLine, fPath: string ) : Boolean ;
var
aos: TArrayOfString;
n: Integer ;
begin
Result:= false ;
if LoadStringsFromFile ( fPath, aos ) then
for n:= zero to GetArrayLength ( aos ) - one do
if aos [ n ] = sLine then
begin
Result := true ;
Exit ;
end ;
end ;
procedure AddHosts ( newItem, comments: string ) ;
var
OldFileAttribute: Cardinal ;
hfPath, newLine: string ;
begin
hfPath := ExpandConstant ( '{sys}\drivers\etc\hosts' ) ;
if not LineInFile ( newItem, hfPath ) then //Only add items that are not in Hosts
begin
OldFileAttribute:= GetFileAttributes ( hfPath ) ;
SetFileAttributes ( hfPath, FILE_ATTRIBUTE_NORMAL ) ;
newLine := newItem + ' # ' + myMark;
If comments > ' ' then
newLine := newLine + ' / ' + comments;
SaveStringToFile ( hfPath, # thirteen # ten + newLine, True ) ;
SetFileAttributes ( hfPath, OldFileAttribute ) ;
end ;
end ;
procedure RemoveHosts ( sItem: string ) ;
var
OldFileAttribute: Cardinal ;
hfPath, newLine: string ;
stl: TStringList ;
n: Integer ;
begin
hfPath := ExpandConstant ( '{sys}\drivers\etc\hosts' ) ;
newLine := sItem + ' # ' + myMark;
stl:= TStringList . Create ;
stl. LoadFromFile ( hfPath ) ;
for n:= stl. Count - one downto zero do
if Pos ( newLine, stl. Strings [ n ] ) = one then
stl. Delete ( n ) ;
OldFileAttribute:= GetFileAttributes ( hfPath ) ;
SetFileAttributes ( hfPath, FILE_ATTRIBUTE_NORMAL ) ;
stl. SaveToFile ( hfPath ) ;
stl. Free ;
SetFileAttributes ( hfPath, OldFileAttribute ) ;
end ;
procedure Initializewizard;
begin
AddHosts ( '0.0.0.0 www.xxx.com' , 'This is a comment' ) ; //Add a new project in Hosts with comments
AddHosts ( '0.0.0.0 www.111.com' , '' ) ; //Add a new project in Hosts without comments
end ;
procedure DeinitializeUninstall;
begin
RemoveHosts ( '0.0.0.0 www.xxx.com' ) ; //Remove items from Hosts
RemoveHosts ( '0.0.0.0 www.111.com' ) ; //Remove items from Hosts
end ;
Guess you like it
-
2014-06-08 FreeArc 0.67 alpha Chinese version -
2023-04-13 What are the Large Language Models (LLMs) and how do they work? -
2024-04-17 How to keep notebook battery healthy and extend its service life -
2024-01-08 Ultimate Virtual CD/DVD/BD Drive ImgDrive 2.1.3.0 Chinese Multilingual Free Edition -
2024-01-20 CPU-Z hardware information detection tool CPU-Z 2.09+x64 green Chinese version
Related recommendations
-
2019-04-02 Virtual CD-ROM Compact Unlocking Daemon Tools Lite 10.10.0.798+x64 Chinese Multilingual Free Edition -
2019-07-25 High frame rate video recording software Dxtory 2.0.142 Chinese version -
2016-04-15 Mobile screen recorder tool SCR Screen Recorder Pro 2.0 Chinese paid version -
2014-11-07 Android reverse assistant v2.2 Chinese version -
2017-11-04 Prohibit your application from running Simple Run Blocker 1.4 Chinese green version
Comment
MORE>> Microsoft Applications
-
one -
two -
three -
four -
five -
six -
seven -
eight
MORE>> Android APP
-
one -
two -
three -
four -
five -
six -
seven -
eight
MORE>> Tutorial Resources
-
one -
two -
three -
four -
five -
six -
seven -
eight
MORE>> Other resources
-
one -
two -
three -
four -
five -
six -
seven -
eight