?? unit_public.pas
字號(hào):
Result:=Current_Year+IntToStr(StrToInt(Current_Month)-2)+'21'
else
begin
if (StrToInt(Current_Day)>20) then //正常的10月份,日期為兩個(gè)位數(shù)
Result:=Current_Year+'0'+IntToStr(StrToInt(Current_Month)-1)+'21'
else
Result:=Current_Year+'0'+IntToStr(StrToInt(Current_Month)-2)+'21';
end;
end;
end;
except
Result := '111111';
end;
end;
function HasInternetConnect:boolean;
var
Reg:Tregistry;
Dat:array[0..3] of char;
begin
//獲取內(nèi)容檢查是否在線?
Reg:=TRegistry.Create;
Reg.RootKey:=Hkey_Local_Machine;
Reg.OpenKey('Syetem\currentcontrolset\services\remoteaccess', false);
Reg.ReadBinaryData('remote connection',Dat,4);
Reg.Free;
Result:=(Dat[0]=#1);
end;
function getIPs: TStrings;
//獲取本機(jī)固定IP地址的另外一種方法 , arthur by zengzc 2001.11
type
TaPInAddr = Array[0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe: PHostEnt;
pptr: PaPInAddr;
Buffer: Array[0..63] of Char;
I: Integer;
GInitData: TWSAData;
begin
WSAStartup($101, GInitData);
Result:=TStringList.Create;
Result.Clear;
GetHostName(Buffer, SizeOf(Buffer));
phe := GetHostByName(buffer);
if phe = nil then
Exit;
pPtr := PaPInAddr(phe^.h_addr_list);
I := 0;
while pPtr^[I] <> nil do
begin
Result.Add(inet_ntoa(pptr^[I]^));
Inc(I);
end;
WSACleanup;
end;
function GetLastIP:string;
//獲取本機(jī)動(dòng)態(tài)IP地址,一般使用于撥號(hào)上網(wǎng), arhtur by zengzc 2001.11
var
WSAData:TWSAData;
HostName:array[0..MAX_COMPUTERNAME_LENGTH] of Char;
HostEnt:PHostEnt;
LastIP:PInAddr;
IPList:^PInAddr;
begin
result:='';
if 0=WSAStartup(MAKEWORD(1,1), WSAData) then
try
if 0=gethostname(HostName, MAX_COMPUTERNAME_LENGTH+1) then
begin
HostEnt:=gethostbyname(HostName);
if HostEnt<>nil then
begin
IPList:=Pointer(HostEnt^.h_addr_list);
repeat
LastIP:=IPList^;
INC(IPList);
until IPList^=nil;
if LastIP<>nil then
result:=inet_ntoa(LastIP^);
end;
end;
finally
WSACleanup;
end;
end;
function GF_UserEnter_Log(EntryModule : String ; //操作人員登陸時(shí)候的模塊名稱
EntryEvt : String ; //操作人員登陸時(shí)候操作的模塊的某一個(gè)按鈕或者事件的名稱
Login_Seq : Integer ; //登陸唯一序列號(hào),如果傳入?yún)?shù)為-1,則登入;否則為退出登陸
Wk_no : String; //操作人員登陸工號(hào)
MEMO:String //具體的操作事件的說(shuō)明
):Integer; //系統(tǒng)返回登陸序列號(hào)(登陸成功返回新的序列號(hào)>0 , 退出登陸成功返回0),失敗返回 -9
{
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 設(shè)計(jì)時(shí)間 : 2002.1.21 @
@ 初始設(shè)計(jì)者 : 曾忠誠(chéng) @
@ 模塊名稱 : @
@ 模塊功能 : 本模塊主要用于把大客戶系統(tǒng)的操作歷史寫(xiě)入數(shù)據(jù)庫(kù) @
@ 輸入 :操作模塊,觸發(fā)事件,登陸序列號(hào),操作工號(hào),操作說(shuō)明 @
@ 注意 : @
@ 對(duì)于多窗體的(MDI)的模式中需要注意的是當(dāng)用戶還沒(méi)有退出該窗體的時(shí)候, @
@ 不要重復(fù)登記該操作歷史,需要把該窗體提到最前面顯示出來(lái),不進(jìn)行操作登記 @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
}
Var
QueryUserLogin : TQuery ; //用于生成序列號(hào)
Query_oper_Log : TQuery ;
New_Seq : Integer;
Str : String ;
Bgn_time: string;//開(kāi)始時(shí)間
begin
QueryUserLogin := TQuery.Create(Application);
Query_oper_Log := TQuery.Create(Application);
QueryUserLogin.DatabaseName := 'db_vip';
Query_oper_Log.DatabaseName := 'db_vip';
If Login_Seq=-1 Then //新增加一個(gè)操作歷史記錄
Begin
try
With QueryUserLogin do
Begin
Close;
SQL.Clear;
SQL.Add('Select '+MP_OperateSeq+'.NextVal New_Seq From Dual');
Open;
End;
New_Seq := QueryUserLogin.FieldByName('New_Seq').AsInteger;
With QueryUserLogin do
Begin
Close;
SQL.Clear;
SQL.Add('select to_char(sysdate,''yyyy-mm-dd hh24:mm:ss'') bgn_time from dual');
Open;
End;
Bgn_Time:=QueryUserLogin.FieldByName('bgn_time').Asstring;
With Query_oper_Log do
Begin
Close;
Sql.Clear;
Sql.Add('insert into '+MP_OperateTable+' (LOG_ID,MODU_NAME,LOG_EVENT,BGN_TIME,Wk_no,LOG_IP,LOG_MEMO)');
Sql.Add(' Values('+inttostr(New_Seq)+','''+EntryModule+''','''+EntryEvt+''', ');
Sql.Add(' '''+Bgn_Time+''','''+Wk_no+''','''+getIPs[0]+''','''+MEMO+''' )');
Execsql;
End;
//不知道為什么關(guān)閉后在數(shù)據(jù)庫(kù)中無(wú)法存入,只有等到關(guān)閉窗口后才能存入
Result := New_Seq; //登入登記成功 返回成功的代碼
GF_SaveAndGetSeq(EntryModule+EntryEvt,New_Seq); //把登陸時(shí)候的ID號(hào)進(jìn)行保存。
except
Result := -9 ; //登入登記失敗
End;
End
Else
Begin
try
Login_Seq := GF_SaveAndGetSeq(EntryModule+EntryEvt,-1); //請(qǐng)求得到某一個(gè)模塊的退出時(shí)間修改的id號(hào)
With QueryUserLogin Do
Begin
Close;
SQL.Clear;
SQL.Add('Update '+MP_OperateTable+' set END_TIME=to_char(sysdate,''yyyy-mm-dd hh24:mm:ss'') where LOG_ID=:update_id');
ParamByName('update_id').AsInteger := Login_Seq;
Prepare;
ExecSQL;
End;
Result := Login_Seq ; //退出登陸登記成功,返回傳入的參數(shù)值
except
Result := -9 ; //退出登陸登記失敗
End;
End;
QueryUserLogin.Free;
Query_oper_Log.Free;
end;
function GF_SaveAndGetSeq(Form_Name : String ; NewSeq : Integer ) : integer ;
{輸入: 窗體的名稱,獲取歷史記錄登記的序列號(hào)
處理: 對(duì)于新的序列號(hào)(NewSeq<>-1)寫(xiě)入注冊(cè)表中\(zhòng)HKEY_LOCAL_MACHINE\SOFTWARE\Doone\VipSystem中,
對(duì)于請(qǐng)求已經(jīng)進(jìn)行保存的需要得到序列號(hào)的時(shí)候(NewSeq=-1)根據(jù)FormName(窗體名稱)找到相對(duì)應(yīng)的登記序列號(hào)
結(jié)果: 對(duì)于新的序列號(hào)的話,返回0 :保存成功 -9 : 返回失敗
對(duì)于請(qǐng)求得到序列號(hào)的時(shí)候,返回 序列號(hào)(>0): 請(qǐng)求成功 -9:請(qǐng)求失敗
}
var
RegVar : TRegistry ;
begin
RegVar := TRegistry.Create;
RegVar.RootKey := HKEY_LOCAL_MACHINE ;
RegVar.OpenKey(RegName,True);
//把需要注冊(cè)的內(nèi)容寫(xiě)入到指定的注冊(cè)表中,不存在的時(shí)候自動(dòng)創(chuàng)建
if NewSeq<>-1 then //寫(xiě)入信息
try
RegVar.WriteInteger(Form_Name,NewSeq);
Result := 0; //寫(xiě)入成功
except
Result := -9; //寫(xiě)入失敗
End
else //讀出信息
try
Result := RegVar.ReadInteger(Form_Name);
except
Result := -9; //讀取失敗
End;
RegVar.Free;
end;
Function CpuType : TCpuType; ASSEMBLER;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@ @
//@ 用匯編來(lái)獲取CPU的型號(hào) @
//@ arthur by zengzc 2001.11.19 @
//@ @
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Asm
// 8086 CPU 檢測(cè)
push ds
pushf
pop bx
mov ax, 0fffh
and ax, bx
push ax
popf
pushf
pop ax
and ax, 0f000h
cmp ax, 0f000h
mov ax, cpu8086
je @@End_CpuType
// 80286 CPU檢測(cè)
or bx, 0f000h
push bx
popf
pushf
pop ax
and ax, 0f000h
mov ax, cpu286
jz @@End_CpuType
// 386 CPU 檢測(cè)
db 66h
pushf
db 66h
pop ax
db 66h
mov cx, ax
db 66h
xor ax, 0h
dw 0004h
db 66h
push ax
db 66h
popf
db 66h
pushf
db 66h
pop ax
db 66h
xor ax, cx
mov ax, cpu386
je @@End_CpuType
// 486 CPU 檢測(cè)
db 66h
pushf
db 66h
pop ax
db 66h
mov cx, ax
db 66h
xor ax, 0h
dw 0020h
db 66h
push ax
db 66h
popf
db 66h
pushf
db 66h
pop ax
db 66h
xor ax, cx
mov ax, cpu486
je @@End_CpuType
// Pentium CPU 檢測(cè)
db 66h
mov ax, 1
dw 0
db 66h
db 0Fh
db 0a2h
db 66h
and ax, 0F00H
dw 0
db 66h
shr ax, 8
sub ax, 1
@@End_CpuType:
pop ds
End;
function GetWindowVersion : String;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@ @
//@ 獲取Windows系統(tǒng)版本號(hào) @
//@ arthur by zengzc 2001.11.19 @
//@ @
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
var
VersionInfo: TOSVersionInfo;
begin
VersionInfo.dwOSVersionInfoSize := Sizeof(TOSVersionInfo);
GetVersionEx(VersionInfo);
case VersionInfo.dwPlatformID of
VER_PLATFORM_WIN32S: Result := 'WIN32S ';
VER_PLATFORM_WIN32_WINDOWS: Result := 'WIN9X ';
VER_PLATFORM_WIN32_NT: Result := 'WINNT ';
end; //獲取到windows的版本號(hào)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -