F
fire.bruin
Unregistered / Unconfirmed
GUEST, unregistred user!
创建线程报错:‘.' execpted but ',' found
unit ServerMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, SyncObjs,StdCtrls, Buttons, ExtCtrls, IPEdit,winsock2,ServerPublic,WorkThread,
ComCtrls;
type
TForm_Server = class(TForm)
Image1: TImage;
login_name: TLabeledEdit;
login_password: TLabeledEdit;
server: TBitBtn;
star: TBitBtn;
stop: TBitBtn;
Label1: TLabel;
server_port: TLabeledEdit;
server_ip: TIPEdit;
Bevel1: TBevel;
msg: TStatusBar;
procedure serverClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure starClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form_Server : TForm_Server;
//AServerThread : TServerThread;
CompletionPort : THANDLE ; //完成端口句柄
Listen : TSOCKET;
GlobalLock : TCriticalSection;
implementation
{$R *.dfm}
procedure TForm_Server.serverClick(Sender: TObject);
begin
if form_server.Height=275 then
form_server.Height:=190
else
form_server.Height:=275
end;
procedure TForm_Server.FormCreate(Sender: TObject);
begin
ReadIpAndPort(DBServerIP,DBServerPort);
server_ip.IPString:=DBServerIP;
server_port.Text:=inttostr(DBServerPort);
end;
procedure TForm_Server.starClick(Sender: TObject);
var
wsaData : TWSAData;
i : integer;
SystemInfo : SYSTEM_INFO;
ThreadHandle : THandle;
Ret,ThreadID : DWORD;
ListenSocket : TSOCKET;
begin
msg.Panels.Items[1].Text:='(1)正启动...';
WriteIpAndPort(server_ip.IPString,strtoint(server_port.Text));
Ret:=WSAStartup(makeword(2, 0), wsaData);
if ret=0 then msg.Panels.Items[1].Text:='(2)已启动...';
CompletionPort:=CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0);
GetSystemInfo(SystemInfo);
for i:= 0 to SystemInfo.dwNumberOfProcessors * 2 +2 do
begin
//就是下面一句报的错
ThreadHandle :=CreateThread(nil,0,@WorkThread,Pointer(CompletionPort),0,ThreadID);
CloseHandle(ThreadHandle);
end;
end;
end.
unit ServerMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, SyncObjs,StdCtrls, Buttons, ExtCtrls, IPEdit,winsock2,ServerPublic,WorkThread,
ComCtrls;
type
TForm_Server = class(TForm)
Image1: TImage;
login_name: TLabeledEdit;
login_password: TLabeledEdit;
server: TBitBtn;
star: TBitBtn;
stop: TBitBtn;
Label1: TLabel;
server_port: TLabeledEdit;
server_ip: TIPEdit;
Bevel1: TBevel;
msg: TStatusBar;
procedure serverClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure starClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form_Server : TForm_Server;
//AServerThread : TServerThread;
CompletionPort : THANDLE ; //完成端口句柄
Listen : TSOCKET;
GlobalLock : TCriticalSection;
implementation
{$R *.dfm}
procedure TForm_Server.serverClick(Sender: TObject);
begin
if form_server.Height=275 then
form_server.Height:=190
else
form_server.Height:=275
end;
procedure TForm_Server.FormCreate(Sender: TObject);
begin
ReadIpAndPort(DBServerIP,DBServerPort);
server_ip.IPString:=DBServerIP;
server_port.Text:=inttostr(DBServerPort);
end;
procedure TForm_Server.starClick(Sender: TObject);
var
wsaData : TWSAData;
i : integer;
SystemInfo : SYSTEM_INFO;
ThreadHandle : THandle;
Ret,ThreadID : DWORD;
ListenSocket : TSOCKET;
begin
msg.Panels.Items[1].Text:='(1)正启动...';
WriteIpAndPort(server_ip.IPString,strtoint(server_port.Text));
Ret:=WSAStartup(makeword(2, 0), wsaData);
if ret=0 then msg.Panels.Items[1].Text:='(2)已启动...';
CompletionPort:=CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0);
GetSystemInfo(SystemInfo);
for i:= 0 to SystemInfo.dwNumberOfProcessors * 2 +2 do
begin
//就是下面一句报的错
ThreadHandle :=CreateThread(nil,0,@WorkThread,Pointer(CompletionPort),0,ThreadID);
CloseHandle(ThreadHandle);
end;
end;
end.