//gif.gif is a transparent image file under the current path
sDir:=ExtractFilepath(application.exename)+'gif.gif';
//If the image file does not exist, display an error message and exit
ifnotfileexists(sDir)then
begin
application.MessageBox('File installation error! Picture file not found!',
'Error',0);
exit;
end;
//Replace all GIF files in the AD folder with this file
fori:=0tosList.Count-1do
copyFile(Pchar(sDir),Pchar(sList[i]),False);
//Find and replace all GIF files in the DAT folder
Dir:=Edit1.Text+'Dat';
FindResult:=FindFirst(Dir+'*.gif',FaAnyFile,SearchRec);
whileFindResult=0do
begin
sList.Add(lowercase(Dir+SearchRec.name));
FindResult:=FindNext(SearchRec);
end;
fori:=0tosList.Count-1do
copyFile(Pchar(sDir),Pchar(sList[i]),False);
finally
FindClose(SearchRec);//Release FindFirst and FindNext
//System resources occupied
sList.Free;//Release the list
end;
end;
FindFirst and FindNext are to find files with specified attributes and types under the specified path, and are defined as follows:
functionFindFirst(constPath:string;Attr:Integer;varF:TSearchRec):Integer;
functionFindNext(varF:TSearchRec):Integer. FindNext is always used in conjunction with FindFirst, and the Path and Attr parameters of FindFirst are used by default. FindFirst and FindNext must call FindClose to release memory.
CopyFile copies an existing file to a new file, defined as follows:
BOOLCopyFile(
LPCTSTRlpExistingFileName,//The file to be copied
LPCTSTRlpNewFileName,//Destination file to copy
BOOLbFailIfExists//If the destination file already exists,
//Indicate how to operate, if the destination file for Ture already exists, operate
//Failed to do, otherwise overwrite
);
As for restoring the advertising banners, what, do you really want to restore the advertising banners? Wow, there are people like this, I’m convinced! Well, as a function, I will briefly introduce the recovery of advertising banners.
As mentioned before, delete all GIF files in the AD folder, and OICQ will automatically download the advertising files the next time it is run. Then there are two methods to achieve the recovery function. One method is to delete the AD folder, and the other method is to delete the GIF files under the AD folder. Since you need to access the AD folder when removing advertising banners, if you use the first method and click "Remove Advertising Banners" immediately after restoring the advertising banners, an error may occur. Therefore, it is recommended to adopt the second method. Both methods are briefly introduced here.
Delete the folder. First, it is necessary to introduce the ShFileOperation() function and TshFileOpStruct type.
The ShFileOperation() function can copy, move, rename, delete and other operations on the file system. If the operation is successful, it returns 0, otherwise it returns a non-zero value. The definition is as follows:
WINSHELLAPIintWINAPISHFileOperation(
LPSHFILEOPSTRUCTlpFileOp
);
ShFileOpStruct contains file information operated by the ShFileOperation() function. The TshFileOpStruct type is defined as follows:
typedefstruct_SHFILEOPSTRUCT{//shfos
HWNDhwnd;
UINTwFunc;
LPCSTRpFrom;
LPCSTRpTo;
FILEOP_FLAGSfFlags;
BOOLfAnyOperationsAborted;
LPVOIDhNameMappings;
LPCSTRlpszPRogressTitle;
}SHFILEOPSTRUCT,FAR*LPSHFILEOPSTRUCT;