我打算用D6做一个远程的监视系统,请高手出招,给我一个方案!200分(200分)

  • 主题发起人 主题发起人 Dephic
  • 开始时间 开始时间
各位大虾,大家好:
我们单位的计算机要处理一个这样的数据库,它只有两个字段,一个是学生的学号,
另一个是存放照片的通用型字段zp,现在我想把每个学生的照片放到该字段中,现在我
知道可以FOXPRO中通过双击该字段把照片插入,但现在的学生有一千多个,我是不是
需要每个照片都这样做呢?这不是太麻烦了吗,我该如何处理这个工作呢?可以节省
我的操作时间与精力。请大家快快帮帮我。
我出一百分的。一定。
如果大家知道此问题的处理方法要很快通知我呀。
谢谢大家。
小虫:志在DELPHI。
2001/6/21
 
志在Delphi,
我觉得有些事情不可以这样做的,比如连续在别人的问题后面添加自己的问题,是对人家的
不尊重。
你(不是说delphic)这个问题不难,只不过是录入图片而已。自己查以前的问题
 
我的问题真的就没有人能回答!
 
看看我的程序虽然是用CB写的,但改成delphi的也很容易。(类pcanywhere)
服务器端:

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include "jpeg.hpp"
#include "server.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "Trayicon"
#pragma resource "*.dfm"
const BufSize=2048;
TForm1 *Form1;
long LeftSize;
TMemoryStream *jpegStream;
DWORD (__stdcall *RegisterServiceProcess)(DWORD dwProcessId,DWORD dwType);
bool clo,yk;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
HINSTANCE hinst=LoadLibrary("KERNEL32.DLL");

DWORD a=GetCurrentProcessId();
(FARPROC)RegisterServiceProcess=GetProcAddress(hinst,"RegisterServiceProcess");
RegisterServiceProcess(a,1);
jpegStream=new TMemoryStream();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ServerSocket1ClientDisconnect(TObject *Sender,
TCustomWinSocket *Socket)
{
jpegStream->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ServerSocket1ClientError(TObject *Sender,
TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int &ErrorCode)
{
ErrorCode=0;
jpegStream->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{
AnsiString rstr;
rstr=Socket->ReceiveText();
if(rstr.SubString(1,5)=="mouse")//&&yk
{
int x,y;
x=StrToInt(rstr.SubString(9,4));
y=StrToInt(rstr.SubString(13,4));
SetCursorPos(x,y);
if(rstr.SubString(6,3)=="dbl")
{
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 );
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 );
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
}
if(rstr.SubString(6,3)=="lef"){
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 );
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
}
if(rstr.SubString(6,3)=="rig"){
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0 );
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0 );
}
}
if (rstr =="show")sendscreen();
if (rstr=="stop")jpegStream->Clear();
if(rstr=="close")
{
clo=true;
Close();
}
}
//---------------------------------------------------------------------------
void TForm1::sendscreen()
{
long sendsize;
char buf[BufSize-1];
if (jpegStream->Size==0)snapscreen();
if (LeftSize>BufSize)
sendsize=BufSize;
else
sendsize=LeftSize;
jpegStream->ReadBuffer(buf,sendsize);
LeftSize=LeftSize-sendsize;
if (LeftSize==0)jpegStream->Clear();
try
{
ServerSocket1->Socket->Connections[0]->SendBuf(buf,sendsize);
}
catch(...)
{
jpegStream->Clear();
}
}


void TForm1::snapscreen()
{
Graphics::TBitmap *bmpscreen= new Graphics::TBitmap();
TJPEGImage *jpegscreen= new TJPEGImage();
HDC ScreenDC;
ScreenDC=GetDC(0);
bmpscreen->Width=Screen->Width;
bmpscreen->Height=Screen->Height;
BitBlt(bmpscreen->Canvas->Handle, 0, 0,Screen->Width,Screen->Height, ScreenDC,0,0, SRCCOPY);
ReleaseDC(0, ScreenDC);
jpegscreen->Assign (bmpscreen);
jpegscreen->CompressionQuality=99;
jpegscreen->SaveToStream (jpegStream);
jpegStream->Position =0;
LeftSize=jpegStream->Size;
bmpscreen->Free();
jpegscreen->Free();
}


void __fastcall TForm1::FormCloseQuery(TObject *Sender, bool &CanClose)
{
CanClose=clo;
}
//---------------------------------------------------------------------------


客户端:

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include "jpeg.hpp"
#include "Unit1.h"
#include "screen.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
const bufsize=2048;
TForm1 *Form1;
TMemoryStream *stream;
TJPEGImage *jpegscreen;
bool isthieve;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------


void __fastcall TForm1::bt_connectClick(TObject *Sender)
{
AnsiString ip=InputBox("建立连接","请输入被察看的机器的IP地址或名称:","172.16.2");
if(ip!="")
{
ClientSocket1->Active=false;
ClientSocket1->Port=15333;
ClientSocket1->Host=ip;
try{
ClientSocket1->Active=true;
}
catch(...)
{
ShowMessage("连接失败!");
}
}

}
//---------------------------------------------------------------------------

void __fastcall TForm1::bt_disconnectClick(TObject *Sender)
{
Form2->Close();
isthieve=false;
ClientSocket1->Active=false;
stream->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::bt_stopClick(TObject *Sender)
{
isthieve=false;
ClientSocket1->Socket->SendText("stop");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::bt_thieveClick(TObject *Sender)
{
isthieve=true;
Form2=new TForm2(this);
Form2->Show();
stream->Clear();
ClientSocket1->Socket->SendText("show");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ClientSocket1Connect(TObject *Sender,
TCustomWinSocket *Socket)
{
ShowMessage("连接成功!");
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ClientSocket1Error(TObject *Sender,
TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int &ErrorCode)
{
ErrorCode=0;
ShowMessage("不能连接!");
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ClientSocket1Read(TObject *Sender,
TCustomWinSocket *Socket)
{
char buf[bufsize];
int numberbytes;
if (isthieve)
{
numberbytes=Socket->ReceiveLength();
Socket->ReceiveBuf(buf,numberbytes);
Socket->SendText("show");
stream->Write(buf,numberbytes);
if(numberbytes<2048){
stream->Position=0;
try{
jpegscreen->LoadFromStream(stream);
Form2->Image1->Picture->Bitmap->Assign(jpegscreen);
}
catch(...){}
stream->Clear();
}
}
if (!isthieve)
Socket->SendText("stop");
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
stream=new TMemoryStream();
stream->Clear();
jpegscreen=new TJPEGImage();
isthieve=false;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::bt_closeClick(TObject *Sender)
{
ClientSocket1->Active=false;
Close();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
ClientSocket1->Socket->SendText("complete");
ClientSocket1->Active=false;
stream->Free();
jpegscreen->Free();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
ClientSocket1->Socket->SendText("close");
if (isthieve)ShowMessage("OK");
}
//---------------------------------------------------------------------------


显示对方机器图像的:

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "screen.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void TForm2::sendkey(TMessage msg)
{

}


void __fastcall TForm2::Image1DblClick(TObject *Sender)
{
tagPOINT xy;
GetCursorPos(&xy);
AnsiString sx,sy;
sx=(IntToStr(xy.x)).SetLength(4);
sy=(IntToStr(xy.y)).SetLength(4);
AnsiString s="mousedbl"+sx+sy;
Form1->ClientSocket1->Socket->SendText(s);
Form1->ClientSocket1->Socket->SendText("show");
}
//---------------------------------------------------------------------------

void __fastcall TForm2::Image1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
if(Shift.Contains(ssLeft))
{
tagPOINT xy;
GetCursorPos(&xy);
AnsiString sx,sy;
sx=(IntToStr(xy.x)).SetLength(4);
sy=(IntToStr(xy.y)).SetLength(4);
AnsiString s="mouselef"+sx+sy;
Form1->ClientSocket1->Socket->SendText(s);
}
else
{
tagPOINT xy;
GetCursorPos(&xy);
AnsiString sx,sy;
sx=(IntToStr(xy.x)).SetLength(4);
sy=(IntToStr(xy.y)).SetLength(4);
AnsiString s="mouserig"+sx+sy;
Form1->ClientSocket1->Socket->SendText(s);
}
}
//---------------------------------------------------------------------------


void __fastcall TForm2::FormClose(TObject *Sender, TCloseAction &Action)
{
this->Free();
}
//---------------------------------------------------------------------------

 
我只会delphi
楼上的不如说说原理+流程
 
对啊!我也不懂C啊!说说原理吧!谢谢了!
 
是这样的:
硬设备:
服务器是有固定合法IP,但客户端是通过局域网使用sygate之类的软件和internet 接通!
要实现:
服务器对各客户端广播!问题是客户端的IP是虚IP,如何才能得到外部IP呢?
谢谢各位大虾了!
 
我把问题再化简一下:
客户机通过代理服务器上网,服务器有固定IP,客户端给服务器发送一个信息后,服务器可以
根据什么向客户机发送信息呢?IP?但这个IP是从哪来的?如果是客户机发过去一个IP包那客户
机又是如何得到这个IP呢?(这个IP应该不会是在局域网中的网内 IP吧)
 
多人接受答案了。
 
后退
顶部