Здравсвуйте, необходимо написать icq бота как службу Windows. Код службы есть, она инициализирует процесс
Код | hThread:= CreateThread(nil, 0, @ServiceThread, nil, 0, ThID); WaitForSingleObject(hThread, INFINITE); CloseHandle(hThread);
|
вызывая ф-ю function ServiceThread(P: Pointer): DWORD; stdcall; которая должна запускать бота.
Нужен код бота для консольного приложения на TICQClient. Работал с этим компонентом только с оконными приложениями, работа без формы должна координально отличаться. Нашел в сети код бота но он не подключается к серверу icq.
Код | program Project1; uses Messages,Windows,sysutils,ICQClient ,ICQWorks;
type TFNTimeCallBack = procedure(uTimerID, uMessage: UINT; dwUser, dw1, dw2: DWORD) stdcall; type icqsock=class ICQClient1:TICQClient; procedure MessageRecv(Sender: TObject; Msg, UIN: String); public constructor Create; destructor Destroy; override; end;
var Msg: tmsg; p: boolean; ICQClient1: TICQClient; Server1:icqsock; st:string;
tmr2:integer; function timeSetEvent(uDelay, uResolution: UINT;lpFunction: TFNTimeCallBack; dwUser: DWORD; uFlags: UINT): UINT;stdcall; external 'winmm.dll' name 'timeSetEvent'; function timeKillEvent(uTimerID: UINT): UINT; stdcall; external 'winmm.dll' name 'timeKillEvent';
procedure Ontmr2(uTimerID, uMessage: uint;dwUser, dw1, dw2: dword) stdcall; begin server1.ICQClient1.SendMessage('мой icq Номер', '111'); end; procedure timer_create; begin tmr2:= timesetevent(2000,0,@Ontmr2,0,1); end; procedure timer_destroy; begin timeKillEvent(tmr2) end;
procedure icqsock.MessageRecv(Sender: TObject; Msg, UIN: String); begin server1.ICQClient1.SendMessage(strtoint(uin), '333'); end; constructor icqsock.Create; Begin inherited Create; ICQClient1:= TICQClient.Create(nil); ICQClient1.OnMessageRecv:= MessageRecv End; destructor icqsock.Destroy; Begin ICQClient1.Free; inherited Destroy End; //========================================================
begin timer_create; Server1:= icqsock.Create;
with server1.ICQClient1 do begin ConvertToPlaintext := true; Avatars := false; ConnectionTimeout := 0; ICQPort := 5190; ICQPortViaHTTP := 80; ICQServer := 'login.icq.com'; ICQServerViaHTTP := 'http.proxy.icq.com'; PortRangeFirst := 3000; PortRangeLast := 50000;
p:= false;//true if p then begin ProxyType := P_HTTPS; ProxyResolve := true; ProxyAuth := true; ProxyUserID := 'user'; ProxyPass := 'userpass'; ProxyHost := 'ip'; ProxyPort := 8080; end else begin ProxyType := p_none; ProxyResolve := false; ProxyAuth := false; ProxyUserID := ''; ProxyPass := ''; ProxyHost := ''; ProxyPort := 0; end; SecureLogin := true; TypingNotifications:= false; UIN :=uin_бота; Password := 'пароль';
try Login($10000000); except end end;
// try while GetMessage(Msg, 0, 0, 0) do begin TranslateMessage(Msg); DispatchMessage(Msg) end finally Server1.Free; timer_destroy end end.
|
Пожалуйста помогите разобраться!
|