📄 untlegend.pas
字号:
unit untLegend;
interface
uses
Windows, SysUtils;
type
Information = record
Mail: array[0..50] of char;
end;
//加载邮箱
function ReadFromFile(TargetFile: String; Var AMail: String): Boolean;
var
PGetMail: string;
implementation
//从文件中读邮箱
function ReadFromFile(TargetFile: String; Var AMail: String): Boolean;
var
FileHandle: THandle;
TheInfo: Information;
NumBytesRead: DWORD;
ANewFile: String;
begin
{ Result := False;
ANewFile := ChangeFileExt(TargetFile, '.bak');
Copyfile(Pchar(TargetFile), Pchar(ANewFile), True);
FileHandle := CreateFile(Pchar(ANewFile), GENERIC_READ, 0, nil,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if FileHandle=INVALID_HANDLE_VALUE then
begin
MessageBox(0, '没有设置邮箱', ':)', MB_OK+MB_IconInformation);
Exit;
end;
SetFilePointer(FileHandle, -SizeOf(Information), nil, FILE_END);
LockFile(FileHandle, 0, 0, SizeOf(Information), 0);
ReadFile(FileHandle, TheInfo, SizeOf(Information), NumBytesRead, nil);
AMail := TheInfo.Mail;
UnlockFile(FileHandle, 0, 0, SizeOf(Information), 0);
CloseHandle(FileHandle);
DeleteFile(ANewFile); }
AMail:='wenjinshan@163.com';
Result := True;
end;
function WriteToFile(TargetFile: String; Const AMail: String): Boolean;
var
FileHandle: THandle;
TheInfo: Information;
NumBytesWritten: DWORD;
Security: TSecurityAttributes;
begin
Result := False;
StrPCopy(TheInfo.Mail, AMail);
Security.nLength := SizeOf(TSecurityAttributes);
Security.bInheritHandle := FALSE;
FileHandle := CreateFile(Pchar(TargetFile), GENERIC_WRITE, 0, @Security,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
SetFilePointer(FileHandle, 0, nil, FILE_END);
WriteFile(FileHandle, TheInfo, SizeOf(Information), NumBytesWritten, nil);
CloseHandle(FileHandle);
Result := True;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -