procedure ButtonStart;
var k:integer;
begin
if attstart=true then
begin
attstart:=false;
WriteCaption(hLabelInfo,pchar('发送开始........'));
ReadCaption(hEditEmail,sbuf);dest:=strpas(sbuf);
ReadCaption(hEditCount,sbuf);count:=strtoint(strpas(sbuf));
ReadCaption(hEditThread,sbuf);Num:=strtoint(strpas(sbuf));
oldtime:=gettickcount();
mcount:=0;
if Num>1000 then Num:=1000;
for k:=1 to Num do
thd[k]:=createthread(nil,0,@fun,nil,0,tid[k]);
end;
end;
procedure ButtonStop;
var k:integer;
begin
for k:=1 to Num do
TerminateThread(thd[k],0);
WriteCaption(handle,exename);
WriteCaption(hLabelInfo,pchar('发送结束'));
attstart:=true;
count:=0;
end;
procedure MainCreate;
begin
attstart:=true;
hMutex:=createmutex(nil,true,'Bome2001');
releasemutex(hMutex);
end;
procedure ButtonHelp;
begin
s1:='本软件只用学习用,不可害人'+CRLF+
'程序使用多线程100个线程,发送速度极快!'+CRLF;
messagebox(handle,pchar(s1),'帮助',0);
end;
//主程序结束
procedure ShutDown;
begin
CloseHandle(hMutex);
//删除字体对象
DeleteObject(hFont);
//取消窗口类的注册
UnRegisterClass(wClass.lpszClassName,hInst);
//结束主进程
ExitProcess(hInst);
end;
//这是主窗口的消息处理函数
function WindowProc(hWnd,Msg,wParam,lParam:integer):Longint; stdcall;
begin
Result:=DefWindowProc(hWnd,Msg,wParam,lParam);
case Msg of
WM_COMMAND:
if lParam=hButtonStart then ButtonStart
else if lParam=hButtonStop then ButtonStop
else if lParam=hButtonHelp then ButtonHelp
else if lParam=hButtonExit then ShutDown;
WM_CREATE:MainCreate;
WM_DESTROY: ShutDown;
end;
end;
//定义几个窗口创建函数
function CreateButton(name:pchar;x1,y1,x2,y2:integer):hwnd;begin
Result:=CreateWindow('Button',name,WS_VISIBLE or WS_CHILD or BS_PUSHLIKE
or BS_TEXT,x1,y1,x2,y2,Handle,0,hInst,nil);end;
function CreateEdit(name:pchar;x1,y1,x2,y2:integer):hwnd;begin
Result:=CreateWindowEx(WS_EX_CLIENTEDGE,'Edit',name,WS_VISIBLE or WS_CHILD
or ES_LEFT or ES_AUTOHSCROLL,x1,y1,x2,y2,Handle,0,hInst,nil);end;
function CreateLabel(name:pchar;x1,y1,x2,y2:integer):hwnd;begin
Result:=CreateWindow('Static',name,WS_VISIBLE or WS_CHILD or
SS_LEFT,x1,y1,x2,y2,Handle,0,hInst,nil);end;
function CreateMain(name:pchar;x1,y1,x2,y2:integer):hwnd;
begin
//取得应用程序实例句柄
hInst:=GetModuleHandle(nil);
//初使化窗口类的信息
with wClass do
begin
Style:= CS_PARENTDC;
hIcon:= LoadIcon(hInst,'MAINICON');
lpfnWndProc:= @WindowProc;
hInstance:= hInst;
hbrBackground:= COLOR_BTNFACE+1;
lpszClassName:= 'MainClass';
hCursor:= LoadCursor(0,IDC_ARROW);
end;
// 注册窗口类
RegisterClass(wClass);
// 建立主窗口
Result:=CreateWindow(wClass.lpszClassName,name,WS_OVERLAPPEDWINDOW or
WS_VISIBLE,x1,y1,x2,y2,0,0,hInst,nil);
end;