?? mainunit.pas
字號(hào):
tempStr := DecodeBase64(tempstr);
end;
// else
// begin
// tempStr := Copy(substr,1,Pos(#13#10,substr)-1);
// end;
MailInfoStr.Add(tempStr);
UpStr:=UpperCase(substr);
substr:=Copy(substr,Pos('TO:',UpStr)+3,Length(UpStr));
tempStr := Copy(substr,1,Pos(#13#10,substr)-1);
if (Pos('=?gb2312?B?',tempStr)<>0) then
begin
tempStr := Copy(tempStr,Pos('?B?',tempStr)+3,(Pos('?=',tempStr)-Pos('?B?',tempStr)-2));
tempStr := DecodeBase64(tempStr);
end;
// else
// begin
// tempStr := Copy(substr,1,Pos(#13#10,substr)-1);
// end;
MailInfoStr.Append(tempStr);
UpStr:=UpperCase(substr);
substr:=Copy(substr,Pos('SUBJECT:',UpStr)+8,Length(UpStr));
tempStr := Copy(substr,1,Pos(#13#10,substr)-1);
if (Pos('=?gb2312?B?',tempStr)<>0) then
begin
tempStr := Copy(tempStr,Pos('?B?',tempStr)+3,(Pos('?=',tempStr)-Pos('?B?',tempStr)-2));
tempStr := DecodeBase64(tempStr);
end;
// else
// begin
// tempStr := Copy(substr,1,Pos(#13#10,substr)-1);
// end;
MailInfoStr.Append(tempStr);
tempItem:=MailInfoList.Items.Add;
tempItem.Caption :=IntToStr(Count);
tempItem.SubItems.Append(MailInfoStr.Strings[Count*3-1]);//subject
tempItem.SubItems.Append(MailInfoStr.Strings[Count*3-3]);//from
tempItem.SubItems.Append(MailInfoStr.Strings[Count*3-2]);//to
end;
procedure TMainForm.GetMailProc(Socket: TCustomWinSocket;Buf:array of char);
var
str,substr:String;
i:integer;
Taskstr:string;
begin
if (Buf[0] = '+')or (Buf[0] = #0) then
begin
Case nStepCount of
0:
begin
TaskIcon.hIcon :=LoadIcon(hInstance,'RUNICON2');
Shell_NotifyIcon(NIM_MODIFY,@TaskIcon);
Label2.Caption :='用戶..';
Socket.SendText('USER '+UserID+#13#10);
nStepCount:=nStepCount+1;
end;
1:
begin
Label2.Caption :='密碼..';
Socket.SendText('PASS '+Password+#13#10);
nStepCount:=nStepCount+1;
end;
2:
begin
TaskIcon.hIcon :=LoadIcon(hInstance,'RUNICON3');
Shell_NotifyIcon(NIM_MODIFY,@TaskIcon);
Label2.Caption :='狀態(tài)..';
Socket.SendText('STAT'+#13#10);
nStepCount:=nStepCount+1;
end;
3:
begin
TaskIcon.hIcon :=LoadIcon(hInstance,'RUNICON4');
Shell_NotifyIcon(NIM_MODIFY,@TaskIcon);
str:=PChar(@Buf);
Label2.Caption :='結(jié)果..';
str:=Copy(str,Pos(' ',str)+1,Length(str)-Pos(' ',str)-1);
substr:=Copy(str,1,Pos(' ',str)-1);
if substr<>'0' then
begin
TaskIcon.hIcon:=LoadIcon(hInstance,'NEWICON');
TaskStr := substr;
Taskstr :='eMail Spy !-'+TaskStr+'封新郵件到了!';
CopyMemory(@TaskIcon.szTip,PChar(Taskstr),Length(Taskstr));
bNewMail:=True;
Shell_NotifyIcon(NIM_MODIFY,@TaskIcon);
Label1.Caption :=' '+substr+'封新郵件到了!';
nMailCount:=StrToInt(substr);
nMailInfoCount:=1;
str:=Copy(Str,Pos(' ',str)+1,Length(str)-Pos(' ',str)-1);
MailInfoBox.Clear;
MailInfoBox.Items.Insert(0,'全部'+str+'字節(jié)');
MailInfoBox.ItemIndex:=0;
Socket.SendText('LIST'+#13#10);
nStepCount:=nStepCount+1;
end
else
begin
Socket.SendText('QUIT'+#13#10);
MailClient.Active :=False;
SocketExitStat;
Hide;
exit;
end;
end;
4:
begin
Socket.ReceiveBuf(Buf,256);
str:=PChar(@Buf);
while Pos('.',str)=0 do
begin
Socket.ReceiveBuf(Buf,256);
str:=PChar(@Buf);
end;
for i:=0 to nMailCount-1 do
begin
subStr:=Copy(str,1,Pos(#13#10,str)-1);
subStr:=Copy(substr,Pos(' ',substr)+1,Length(substr));
MailInfoBox.Items.Insert(i+1,'第'+IntToStr(i+1)+'封:'+substr+'字節(jié)');
str:=Copy(str,Pos(#13#10,str)+2,Length(str));
end;
if (bIsMore) and (nMailInfoCount<nMailCount+1) then
begin
// Socket.SendText('NOOP'+#13#10);
Socket.SendText('TOP '+IntToStr(nMailInfoCount)+' 0'+#13#10);//0 is the Part 0,this is Head message; Socket.SendText('TOP 1 0'+#13#10);//0 is the Part 0,this is Head message;
nStepCount:= 6;///nStepCount+1;
MailInfoList.Items.Clear;
end
else
begin
Beep;
if bShowForm then
Show;
MailInfoBox.Enabled :=True;
Socket.SendText('QUIT'+#13#10);
MailClient.Active :=False;
SocketExitStat;
exit;
end;
end;
5:
begin
Socket.SendText('TOP '+IntToStr(nMailInfoCount)+' 0'+#13#10);//0 is the Part 0,this is Head message; Socket.SendText('TOP 1 0'+#13#10);//0 is the Part 0,this is Head message;
nStepCount:=nStepCount+1;
end;
6:
begin
if Buf[0] <> #0 then
begin
str:=PChar(@Buf);
GetMailInfo(str,nMailInfoCount);
if nMailInfoCount<nMailCount then
begin
nMailInfoCount:=nMailInfoCount+1;
nStepCount:=5;
Socket.SendText('NOOP'+#13#10);
exit;
end
else
begin
Beep;
if bShowForm then
Show;
MailInfoBox.Enabled :=True;
Socket.SendText('QUIT'+#13#10);
MailClient.Active :=False;
SocketExitStat;
exit;
end;
end;
end;
end;
end
else
begin
if MailClient.Active then
MailClient.Active :=False;
if Buf[0] = '-' then
begin
if bRetype then
begin
AuthenticationFailed;
end
else
begin
if bAutoAgain then
begin
TaskIcon.hIcon:=LoadIcon(hInstance,'TRYICON');
TaskIcon.szTip :='eMail Spy !-自動(dòng)重試..';
Shell_NotifyIcon(NIM_MODIFY,@TaskIcon);
Label1.Caption :='自動(dòng)重試..';
end
else
begin
EnableMenu.Caption:='啟用(&E)';
TaskIcon.hIcon:=LoadIcon(hInstance,'ZENABLEDICON');
TaskIcon.szTip :='eMail Spy !-停止.';
Shell_NotifyIcon(NIM_MODIFY,@MainForm.TaskIcon);
Label1.Caption :='停止.';
Timer1.Enabled :=False;
end;
end;
end;
end;
end;
procedure TMainForm.DeleteMailProc(Socket: TCustomWinSocket;Buf:array of char;Num:integer);
begin
if (Buf[0]='+') then
begin
Case nStepCount of
0:
begin
Label2.Caption :='用戶';
Socket.SendText('USER '+UserID+#13#10);
nStepCount:=nStepCount+1;
end;
1:
begin
Label2.Caption :='密碼';
Socket.SendText('PASS '+Password+#13#10);
nStepCount:=nStepCount+1;
end;
2:
begin
Label2.Caption :='刪除';
Socket.SendText('DELE '+IntToStr(nDeleteMailNo)+#13#10);
nStepCount:=nStepCount+1;
end;
3:
begin
Label2.Caption :='關(guān)閉';
Socket.SendText('QUIT'+#13#10);
nStepCount:=nStepCount+1;
end;
4:
begin
// MailClient.Active :=False;
Label2.Caption :='斷連';
SocketExitStat;
end;
end;
end
else
begin
MessageDlg('刪除郵件時(shí)錯(cuò)誤。',mtWarning,[mbYes],0);
MoreBtnClick(nil);
PostMessage(Handle,MSG_CHECK_MAIL,0,0);
bDeleteMail :=False;
Socket.SendText('QUIT'+#13#10);
MailClient.Active :=False;
SocketExitStat;
end;
end;
procedure TMainForm.MailClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
buf:array[0..5119] of Char;
begin
FillChar(Buf,5120,#0);
StrPCopy(@Buf,Socket.ReceiveText);
if bDeleteMail then
DeleteMailProc(Socket,Buf,nDeleteMailNo)
else
GetMailProc(Socket,Buf);
end;
procedure TMainForm.SocketExitStat;
begin
if bNewMail = False then
begin
if EnableMenu.Caption ='禁用(&D)' then
begin
TaskIcon.szTip :='eMail Spy !-偵測(cè)..';
TaskIcon.hIcon :=LoadIcon(hInstance,'MAINICON');
Shell_NotifyIcon(NIM_MODIFY,@TaskIcon);
Label1.Caption :='偵測(cè)..';
end
else
begin
TaskIcon.hIcon:=LoadIcon(hInstance,'ZENABLEDICON');
TaskIcon.szTip :='eMail Spy !-停止.';
Shell_NotifyIcon(NIM_MODIFY,@TaskIcon);
Label1.Caption :='停止.';
end;
end;
end;
procedure TMainForm.MoreBtnClick(Sender: TObject);
var
H:integer;
tempBmp:TBitmap;
begin
if bIsMore then
begin
tempBmp:=TBitmap.Create;
if bMore then
begin
Height := 93;
Width := 199;
tempBmp.LoadFromResourceName(HInstance,'MOREDOWN');
MoreBtn.Glyph.Assign(tempBmp);
bMore := False;
end
else
begin
H:=MailInfoList.Items[0].DisplayRect(drBounds).Bottom-MailInfoList.Items[0].DisplayRect(drBounds).Top;
Height := 120+(nMailCount)*H;
if Height >247 then
Height :=247;
Width := 335;
tempBmp.LoadFromResourceName(HInstance,'MOREUP');
MoreBtn.Glyph.Assign(tempBmp);
bMore := True;
end;
tempBmp.Free;
end
else
begin
if WinExec('SpySetup.exe',SW_SHOWNORMAL)<31 then
begin
MessageDlg('無法定位Sypsetup.exe程序,請(qǐng)檢查其是否與eMailSpy.exe在同一個(gè)目錄下',mtWarning,[mbYes],0);
Exit;
end;
end;
end;
procedure TMainForm.FormActivate(Sender: TObject);
begin
if bNewMail=False then
begin
Timer1Timer(Sender);
PostMessage(Handle,WM_SYSCOMMAND,SC_MINIMIZE,0);
end;
end;
procedure TMainForm.MailInfoListMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
tempPoint:TPoint;
begin
if Button=mbRight then
begin
tempPoint.x := X;
tempPoint.y := Y;
DeleteMenu.Visible :=True;
EnableMenu.Visible :=False;
HideSpyMenu.Visible :=True;
OptionMenu.Visible :=False;
AboutMenu.Visible :=False;
ExitMenu.Visible :=False;
CheckNowMenu.Visible :=False;
tempPoint:=(TControl(Sender)).ClientToScreen(tempPoint);
PopMenu.Popup(tempPoint.x,tempPoint.y);
end;
end;
procedure TMainForm.DeleteMenuClick(Sender: TObject);
begin
if MailInfoList.Selected<>nil then
begin
Hide;
nDeleteMailNo:=MailInfoList.Selected.Index +1;
bDeleteMail:=True;
MailClient.Active := True;
end
else
MessageDlg('那一封 ?',mtConfirmation,[mbYes],0);
end;
procedure TMainForm.CheckMail(var Msg:TMessage);
begin
CheckNowMenuClick(nil);
end;
procedure TMainForm.HideSpyMenuClick(Sender: TObject);
begin
MoreBtnClick(nil);
Hide;
end;
procedure TMainForm.MailClientError(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
if MailClient.Active then
MailClient.Active := false;
if Timer1.Enabled then
Timer1.Enabled := false;
bNewMail := false;
EnableMenu.Caption := '啟用(&E)';
SocketExitStat;
MessageDlg('可能鏈路連接上出現(xiàn)故障,eMailspy!已自動(dòng)停止。',mtWarning,[mbYes],0);
ErrorCode := 0;
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -