Global.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:11k
- unit Global;
- interface
- uses
- Classes,ComCtrls,Types,Windows,SysUtils,md5,IdTCPServer,MySocket;
- Const
- FilePackSize=1280;
- var
- skLogin :Char=#1;
- skStateChanged :Char=#2;
- skLoginResult :Char=#3;
- skSendBranch :Char=#4;
- skSendEmployee :Char=#5;
- skOnlineCheck :Char=#6;
- skMessage :Char=#7;
- skReturnMessage :Char=#8;
- skSendFileRequest :Char=#9;
- skSendFileResponse :Char=#10;
- skSendFilePackage :Char=#11;
- skSendFileResult :Char=#12;
- skSendFileCancle :Char=#13;
- skSendFileStop :Char=#14;
- skSendFileCompleted :Char=#15;
- skSendFileResume :Char=#16;
- skAddUser :Char=#17;
- skAudio :Char=#18;
- skAudioRequest :Char=#19;
- skAudioResponse :Char=#20;
- skAudioCancel :Char=#21;
- skAudioStop :Char=#22;
- skVideoRequest :Char=#23;
- skVideoCancel :Char=#24;
- skVideoResponse :Char=#25;
- skVideoStop :Char=#26;
- skVideo :Char=#27;
- skSetBitmapInfo :Char=#28;
- skSetCompvars :Char=#29;
- skInputing :Char=#30;
- skGetMyIPAndPort :Char=#31;
- skPleaseCallMe :Char=#32;
- skCallSomeone :Char=#33;
- skCalled :char=#34;
- skP2PResponse :char=#35;
- skBeginTalk :char=#36;
- skPleaseUseTCP :char=#37;
- skChangeNameAndPassword:char=#38;
- skNameAndPasswordChanged:char=#39;
- type
- TCBChangeNameAndPassword = record
- ID:Integer;
- Name:String[40];
- Password:String[20];
- end;
- TCBNameAndPasswordChanged = record
- ID:Integer;
- Name:String[40];
- end;
- TCBPleaseUseTCP = record
- Receiver,
- Sender :Integer;
- ForAudioAudio,
- ForVideoAudio,
- ForVideoVideo:Boolean;
- end;
- TCBBeginTalk = record
- Receiver,
- Sender :Integer;
- LocalIP :String[15];
- LocalPort :Integer;
- IP :String[15];
- Port :Integer;
- end;
- TCBCalled = record
- Receiver,
- Sender :Integer;
- IP :String[15];
- Port :Integer;
- end;
- TCBP2PResponse = record
- Receiver,
- Sender :Integer;
- IP :String[15];
- Port :Integer;
- PeerIP :String[15];
- PeerPort :Integer;
- UseIP :String[15];
- UsePort :Integer;
- end;
- TCBCallSomeone = record
- Receiver,
- Sender :Integer;
- IP :String[15];
- Port :Integer;
- end;
- TCBGetMyIPAndPort = record
- Sender :Integer;
- LocalIP :String[15];
- LocalPort :Integer;
- IP :String[15];
- Port :Integer;
- end;
- TCBPleaseCallMe = record
- Receiver,
- Sender :Integer;
- IP :String[15];
- Port :Integer;
- MyLocalIP :String[15];
- MyLocalPort :Integer;
- MyIP :String[15];
- MyPort :Integer;
- UseIP :String[15];
- UsePort :Integer;
- end;
- TCBSetBitmapInfo = record
- Receiver :Integer;
- Buf :array [0..255] of byte;
- end;
- TCBSetCompvars = record
- Receiver :Integer;
- Buf :array [0..255] of byte;
- end;
- ChatRoom = record
- UserCount :Integer;
- Users :Array [1..16] of Integer;
- end;
- TCBAddUser = record
- Receiver:Integer;
- AddRoom :ChatRoom;
- Room :ChatRoom;
- end;
- TCBInputing = record
- Receiver :Integer;
- Sender :Integer;
- Inputing :Boolean;
- Room :ChatRoom;
- end;
- TCBVideo = record
- Receiver :Integer;
- Sender :Integer;
- PackCount :Integer;
- PackNO :Integer;
- BufLength :Integer;
- Buf :array [1..460] of byte;
- bKeyFrame :Boolean;
- nSampleNum :DWORD;
- nAllSize :DWORD;
- end;
- TCBVideoStop = record
- Receiver :Integer;
- Sender :Integer;
- end;
- TCBVideoResponse = record
- Receiver :Integer;
- Sender :Integer;
- isAcepted :Boolean;
- ALocalIP :String[15];
- ALocalPort :Integer;
- AIP :String[15];
- APort :Integer;
- VLocalIP :String[15];
- VLocalPort :Integer;
- VIP :String[15];
- VPort :Integer;
- end;
- TCBVideoRequest = record
- Receiver :Integer;
- Sender :Integer;
- Room :ChatRoom;
- ALocalIP :String[15];
- ALocalPort :Integer;
- AIP :String[15];
- APort :Integer;
- VLocalIP :String[15];
- VLocalPort :Integer;
- VIP :String[15];
- VPort :Integer;
- end;
- TCBVideoCancel = record
- Receiver :Integer;
- Sender :Integer;
- end;
-
- TCBAudio = record
- Receiver,
- Sender :Integer;
- lpData :Array [1..260] of char;
- dwBufferLength,
- MMLevelValue:Cardinal;
- end;
- TCBAudioCancel = record
- Receiver :Integer;
- Sender :Integer;
- end;
- TCBAudioStop = record
- Receiver :Integer;
- Sender :Integer;
- end;
- TCBAudioRequest = record
- Receiver :Integer;
- Sender :Integer;
- Room :ChatRoom;
- LocalIP :String[15];
- LocalPort :Integer;
- IP :String[15];
- Port :Integer;
- end;
- TCBAudioResponse = record
- Receiver :Integer;
- Sender :Integer;
- isAcepted :Boolean;
- LocalIP :String[15];
- LocalPort :Integer;
- IP :String[15];
- Port :Integer;
- end;
- TCBSendFilePackage = record
- Receiver :Integer;
- BaseID :String[80];
- Position :Int64;
- Length :Integer;
- Package :Array[1..FilePackSize] of char;
- MD5Code :MD5Digest;
- SendTicket :Int64;
- end;
- TCBSendFileReportPoint = record
- Position:Integer;
- IsAccepted:char;
- end;
-
- TCBSendFileResult = record
- Receiver :Integer;
- BaseID :String[80];
- CurentSize :Int64;
- SendTicket :Int64;
- end;
- TCBSendFileRequest = record
- Receiver :Integer;
- Sender :Integer;
- FileID :String[32];
- BaseID :String[80];
- FileName :String[100];
- FileSize :Int64;
- IsScreen :Boolean;
- Room :ChatRoom;
- LocalIP :String[15];
- LocalPort :Integer;
- IP :String[15];
- Port :Integer;
- end;
- TCBSendFileResponse = record
- Receiver :Integer;
- IsAccept :Boolean;
- BaseID :String[80];
- LocalIP :String[15];
- LocalPort :Integer;
- IP :String[15];
- Port :Integer;
- end;
- TCBSendFileCancle = record
- Receiver :Integer;
- BaseID :String[80];
- end;
- TCBSendFileStop = record
- Receiver :Integer;
- Sender :Integer;
- BaseID :String[80];
- end;
- TCBSendFileCompleted = record
- Receiver :Integer;
- Sender :Integer;
- BaseID :String[80];
- end;
- TCBSendFileResume = record
- Receiver :Integer;
- Sender :Integer;
- BaseID :String[80];
- Start :Integer;
- BufferLength:Integer;
- ResumBuffer :array[1..400] of Char;
- end;
- TCBLogin = record
- LoginName,
- Password :String[20];
- State :String[20];
- LocalIP :String[15];
- LocalPort :Integer;
- MACNO :String[30];
- HaveAudioDevice,
- HaveVideoDevice :Boolean;
- Version :Integer;
- end;
- TCBLoginResult = record
- IsLogin :Boolean;
- Result :String[80];
- end;
- TCBStateChanged = record
- ID :Integer;
- State :String[20];
- HaveAudioDevice,
- HaveVideoDevice,
- IsAutoState :Boolean;
- end;
- PCBMessage = ^TCBMessage;
- TCBMessage = record
- Receiver :Integer;
- Sender :Integer;
- Length :Integer;
- SendDateTime :TDateTime;
- SendTicket :Cardinal;
- Name :string[20];
- Color,
- Size :Integer;
- fsBold,
- fsItalic,
- fsUnderline,
- fsStrikeOut :Boolean;
- Content :array[1..370] of Char;
- Room :ChatRoom;
- end;
- TCBReturnMessage = record
- Receiver :Integer;
- Sender :Integer;
- Length :Integer;
- SendTicket :Cardinal;
- end;
- PBranch = ^Branch;
- Branch = record
- ID,
- ParentID :Integer;
- Name :String[60];
- Position :Integer;
- Node :TTreeNode;
- end;
- PEmployee = ^Employee;
- Employee = record
- ID,
- BranchID :Integer;
- LoginName,
- Password :String[20];
- Name :String[40];
- Sex :String[1];
- State :String[20];
- ToolTips :String[100];
- IsMe :Boolean;
- LocalIP :String[15];
- LocalPort :Integer;
- IP :String[15];
- Port :Integer;
- MACNO :String[30];
- HaveAudioDevice,
- HaveVideoDevice :Boolean;
- LastActive :Cardinal;
- Position :Integer;
- Node :TTreeNode;
- AThread :TIdPeerThread;
- MySocket :TMySocket;
- end;
- TCBSendBranch = record
- Current,
- Count :Integer;
- BranchData:Branch;
- end;
- TCBSendEmployee = record
- Current,
- Count :Integer;
- EmployeeData:Employee;
- end;
- Const
- ServerStopped='服务器已停止!';
- PasswordError='请检查用户名和密码!';
- SameUserJustLogin='相同的用户在其它位置刚刚登录!';
- UserIsDeleted='您所使用的帐号已被删除!';
- NeedNewVersion='请从imp2p.Net下载最新版程序!';
- function GetFileVersion(FileName: string;var Major1, Major2, Minor1, Minor2: Integer):String;
- implementation
- function GetFileVersion(FileName: string;var Major1, Major2, Minor1, Minor2: Integer):String;
- var
- Info: Pointer;
- InfoSize: DWORD;
- FileInfo: PVSFixedFileInfo;
- FileInfoSize: DWORD;
- Tmp: DWORD;
- begin
- Result:='';
- InfoSize := GetFileVersionInfoSize(PChar(FileName), Tmp);
- Major1 := 0; Major2 := 0; Minor1 := 0; Minor2 := 0;
- if InfoSize = 0 then
- else
- begin
- GetMem(Info, InfoSize);
- try
- GetFileVersionInfo(PChar(FileName), 0, InfoSize, Info);
- VerQueryValue(Info, '', Pointer(FileInfo), FileInfoSize);
- Major1 := FileInfo.dwFileVersionMS shr 16;
- Major2 := FileInfo.dwFileVersionMS and $FFFF;
- Minor1 := FileInfo.dwFileVersionLS shr 16;
- Minor2 := FileInfo.dwFileVersionLS and $FFFF;
- Result:=IntToStr(Major1)+'.'+IntToStr(Major2)+'.'+IntToStr(Minor1)+'.'+IntToStr(Minor2);
- finally
- FreeMem(Info, FileInfoSize);
- end;
- end;
- end;
- end.