YE
unit Unit1;
(* -----------------------------------------------------------------------------
单元说明:USB加密狗网络版客户端演示程序
版权:深圳XX公司
作者:陈经韬
创建日期:2003,9,3.
修改记录:9.5
----------------------------------------------------------------------------- *)
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,WinSock, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
ServerSocket:TSocket;
addr_Server: TSockAddrIn;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses UsbDogUnit;
const LibName='UsbDogNetDll.dll';
function NetServerStart(const ParentHandle:THandle; var ServerSocket:TSocket; var addr_Server: TSockAddrIn;const IpAddress:string;const Port:integer;const ShowMsg:Boolean=False):Boolean;external LibName;
procedure NetServerStop;external LibName;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
if not NetServerStart(Handle,ServerSocket,addr_Server,'234.5.6.7',987{,True}) then
begin
Application.MessageBox('无法初始化网络模块!',Pchar(Application.Title),MB_ICONINFORMATION);
Application.Terminate;
end;
Timer1.Enabled:=True;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
StrSend:String;
begin
Timer1.Enabled:=False;
if UsbDog_ReadStr(StrSend) then
Sendto(ServerSocket, StrSend[1],Length(StrSend), 0, addr_Server, sizeof(addr_Server))
else
begin
Application.MessageBox('无法取USB加密狗数据!',Pchar(Application.Title),MB_ICONINFORMATION);
Application.Terminate;
end;
Timer1.Enabled:=True;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
NetServerStop;
end;
end.
其中UsbDogNetDll.dll就是用D写的.11KB