📄 ucommon.~pas
字号:
unit uCommon;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,mmSystem,
StdCtrls, Buttons, ExtCtrls, Grids, DBGrids, ComCtrls, Db, DBTables,inifiles,Nb30,
Winsock,WiniNet;
//设定ShowModal窗体初始位置
procedure SetWindowPosition(aForm:TForm);
function iif(TJ:Bool;ResultA,ResultB:Variant):Variant;
function fDatestr(dat:Tdate;i:integer):string;
//取网卡地址(MAC)列表
procedure NBGetMac(Strings: TStrings);
//取第一个非零的网卡地址
function NBGetFirstMac: String;
//判断指定网卡地址是否存在
function NBIsMacInList(Mac: String): Boolean;
function Decode(ADest: string): string;
function Encode(ASour: string): string;
var
GG_SpellCode:String;
GG_WBCode:String;
GG_StaffID:integer; //员工ID
GG_StaffNO:String; //员工工号
GG_StaffName:string; //员工姓名
GG_LoginMiMa:string; //员工登录密码
GG_StaffClass:string; //员工权限
GG_MachineNo:String; //机器号
GG_NetMAC:string; //加密号
//ini
pDBIniFile:TIniFile;
gg_IniFilePath:string;
Form_MediInStock_Flags:bool; //药品入库窗体标示
const
FKey='dddddddgdshagdhswwwwwdgfsgafdgsafdg'; //密吗
SysTemImeName='中文 (简体) - 美式键盘'; //系统默认输入法
cc_IniFileName='Clothes.ini'; //配置文件名
Normal_Status='01'; //正常
Discard_Status='02'; //作废
Suspend_Status='03'; //挂单
Invoice_Status='07'; //已经打过发票的
implementation
procedure SetWindowPosition(aForm:TForm);
begin
{height:533; width:655; left:144; top:39 }
with aForm do
begin
//Height:=533;
//Top:=655;
Left:=144;
Top:=39;
end;
end;
function iif(TJ:Bool;ResultA,ResultB:Variant):Variant;
begin
if TJ then
Result:=ResultA
else
Result:=ResultB;
end;
function fDatestr(dat:Tdate;i:integer):string;
var y,m,d:word;
begin
decodedate(dat,y,m,d);
case i of
1: //yyyy/mm/dd
fDatestr:=formatdatetime('yyyy"/"mm"/"dd',dat);
2: //YYYY年MM月DD
fDatestr:=formatdatetime('yyyy"年"mm"月"dd"日"',dat);
3: //YYYYMMDD
fDatestr:=formatdatetime('yyyymmdd',dat);
4: //YYMMDD
fDatestr:=formatdatetime('yymmdd',dat);
5: //YYYY-MM-DD
fDatestr:=formatdatetime('yyyy"-"mm"-"dd',dat);
6:
fDatestr:=formatdatetime('yyyy"-"mm"-"dd',dat)+' 00:00:00';
7:
fDatestr:=formatdatetime('yyyy"-"mm"-"dd',dat)+' 23:59:59';
end;
end;
function NBGetFirstMac: String;
var
Strings: TStringList;
I, J: Integer;
begin
Result := '';
Strings := TStringList.Create;
try
NBGetMac(Strings);
for I := 0 to Strings.Count - 1 do
begin
for J := 1 to Length(Strings.Strings[I]) do
if (Strings.Strings[I][J] <> '0') and
(Strings.Strings[I][J] <> '-') then
begin
Result := Strings.Strings[I];
Break;
end;
if Result <> '' then Break;
end;
finally
Strings.Free;
end;
end;
procedure NBGetMac(Strings: TStrings);
function HexBL(by: Byte): String;
begin
Result := Format('%x', [by]);
if Length(Result) < 2 then
Result := '0' + Result;
end;
var
NCB: TNCB;
Adapter: TAdapterStatus;
LanaEnum: TLanaEnum;
I, J: Integer;
Str: String;
begin
Strings.Clear;
ZeroMemory(@NCB,SizeOf(NCB));
NCB.ncb_command := Chr(NCBENUM);
NetBios(@NCB);
NCB.ncb_buffer := @LanaEnum;
NCB.ncb_length := SizeOf(LanaEnum);
NCB.ncb_command := Chr(NCBENUM);
NetBios(@NCB);
for I := 0 to Ord(LanaEnum.length) - 1 do
begin
ZeroMemory(@NCB,SizeOf(NCB));
NCB.ncb_command := Chr(NCBRESET);
NCB.ncb_lana_num := LanaEnum.lana[I];
NetBios(@NCB);
ZeroMemory(@NCB,SizeOf(NCB));
NCB.ncb_command := Chr(NCBASTAT);
NCB.ncb_lana_num := LanaEnum.lana[I];
StrPCopy(NCB.ncb_callname,'*');
NCB.ncb_buffer := @Adapter;
NCB.ncb_length := SizeOf(Adapter);
NetBios(@NCB);
Str := '';
for J := 0 to 5 do
begin
if J > 0 then Str := Str + '-';
Str := Str + HexBL(Byte(Adapter.adapter_address[J]));
end;
Strings.Add(Str);
end;
end;
function NBIsMacInList(Mac: String): Boolean;
var
Strings: TStringList;
I: Integer;
begin
Result := False;
Strings := TStringList.Create;
try
NBGetMac(Strings);
for I := 0 to Strings.Count - 1 do
begin
if Strings.Strings[I] = Mac then
begin
Result := True;
Break;
end;
end;
finally
Strings.Free;
end;
end;
function Decode(ADest: string): string;
var
I: Integer;
ASour: string;
begin
Result := '';
if Length(ADest) > Length(FKey) then Exit;
ASour := '';
for I:= 1 to Length(ADest) do
begin
ASour := ASour + chr(ord(ADest[I]) xor ord(FKey[I]));
end;
Result := ASour;
end;
function Encode(ASour: string): string;
var
I: Integer;
ADest: string;
begin
Result := '';
if Length(ASour) > Length(FKey) then Exit;
ADest := '';
for I := 1 to Length(ASour) do
ADest:= ADest + chr(ord(ASour[I]) xor ord(FKey[I]));
Result:=ADest;
end;
initialization
{try
gg_IniFilePath:=ExtractFilePath(ParamStr(0))+cc_IniFileName;
if FileExists(gg_IniFilePath) then
begin
pDBIniFile:=TIniFile.Create(gg_IniFilePath);
try
GG_MachineNo:=pDBIniFile.ReadString('Setup','Machine_HAO','01');
GG_NetMAC:=pDBIniFile.ReadString('Setup','Machine','01000000');
finally
pDBIniFile.Free;
end;
end
else begin
ShowMessage('File Not Find!');
Application.Terminate;
end;
finally
end; }
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -