谢谢大家对我一直以来的帮助你们是我的偶像太感谢你们了,请再帮我看下这个定时器函数错在哪里?分不多因为在下真的很穷了。 ( 积分: 10 )

  • 主题发起人 landy2005t
  • 开始时间
L

landy2005t

Unregistered / Unconfirmed
GUEST, unregistred user!
ar
Form1: TForm1;
hand:hwnd;
procedure kill;
implementation

{$R *.dfm}
procedure kill;
begin
sendmessage(hand,wm_syscommand,sc_close,0);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
hand:=findwindow('#32770',0);
edit1.text:=floattostr(hand);
settimer(hand,1,100,@kill);
end;

end.

不知道为什么这个定时器里面的代码根本没有执行不知道为什么?
望指教我是想学一下这个定时器函数。settimer.
 
ar
Form1: TForm1;
hand:hwnd;
procedure kill;
implementation

{$R *.dfm}
procedure kill;
begin
sendmessage(hand,wm_syscommand,sc_close,0);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
hand:=findwindow('#32770',0);
edit1.text:=floattostr(hand);
settimer(hand,1,100,@kill);
end;

end.

不知道为什么这个定时器里面的代码根本没有执行不知道为什么?
望指教我是想学一下这个定时器函数。settimer.
 
program Sender;

uses
Windows, ScktComp;

const
SendData ='POST /cgi-bin/internal/top/vote HTTP/1.1'#13#10+
'Accept: */*'#13#10'Referer: http://ent.sina.com.cn/v/f/sdxl/index.html'#13#10+
'Accept-Language: zh-cn'#13#10+
'Content-Type: application/x-www-form-urlencoded'#13#10+
'Accept-Encoding: gzip, deflate'#13#10+
'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; Hotbar 4.4.6.0; .NET CLR 1.1.4322)'#13#10+
'Host: survey.sina.com.cn'#13#10+'Content-Length: 27'#13#10+
'Connection: Keep-Alive'#13#10+'Cache-Control: no-cache'#13#10+
'Cookie:'#13#10#13#10+'answer=1&id=9994&inv_type=1';

var
ClientSocket1 : TClientSocket;
MyNotifyEvent : TSocketNotifyEvent;
MyErrorEvent : TSocketErrorEvent ;
MyThreadMessage : tagMSG;


//----时钟回调----
procedure TimerProc( hwnd:HWND; uMsg:UINT; idEvent:UINT; dwTime:DWORD );stdcall;
begin
if ClientSocket1.Active = True then ClientSocket1.Close;
ClientSocket1.Open;
end;

//----错误事件---- {--隐含参数--}
procedure ClientSocket1Error( Self: TObject; Sender: TObject; Socket: TCustomWinSocket;
ErrorEvent: TErrorEvent; var ErrorCode: Integer);
begin
ErrorCode:=0;
Socket.Close;
end;

//----连接事件---- {--隐含参数--}
procedure ClientSocket1Connect( Self: TObject; Sender: TObject;Socket: TCustomWinSocket);
begin
Socket.SendText(SendData);
Socket.SendText(SendData);
end;

//----------主程序-------
Begin
{--建立对象--}
ClientSocket1:=TClientSocket.Create(nil);
{--设置属性--}
if ClientSocket1.Active = True then ClientSocket1.Close;
ClientSocket1.ClientType:=ctNonBlocking ;
ClientSocket1.Host := 'survey.sina.com.cn' ;
ClientSocket1.Port := 80 ;

{--接事件处理过程--}
TMethod(MyErrorEvent).Code := @ClientSocket1Error;
TMethod(MyErrorEvent).Data := ClientSocket1;
ClientSocket1.OnError := MyErrorEvent;

TMethod(MyNotifyEvent).Code := @ClientSocket1Connect;
TMethod(MyNotifyEvent).Data := ClientSocket1;
ClientSocket1.OnConnect := MyNotifyEvent ;
{--安装时钟--}
SetTimer(0,0,2000,@TimerProc);
{--消息循环--}
While GetMessage(MyThreadMessage,0,0,0) do
DispatchMessage(MyThreadMessage);

end.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
630
import
I
I
回复
0
查看
649
import
I
顶部