⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit_public.pas

📁 delphi开发的中国移动大客户管理系统,后台数据库为oracle
💻 PAS
📖 第 1 页 / 共 5 页
字号:
          Result:=Current_Year+IntToStr(StrToInt(Current_Month)-2)+'21'
        else
        begin
          if (StrToInt(Current_Day)>20) then  //正常的10月份,日期为两个位数
            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
  //获取内容检查是否在线?
  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;
//获取本机固定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;
//获取本机动态IP地址,一般使用于拨号上网, 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 ;  //操作人员登陆时候的模块名称
                          EntryEvt    : String ;  //操作人员登陆时候操作的模块的某一个按钮或者事件的名称
                          Login_Seq   : Integer ;  //登陆唯一序列号,如果传入参数为-1,则登入;否则为退出登陆
                          Wk_no       : String;   //操作人员登陆工号
                          MEMO:String              //具体的操作事件的说明
                          ):Integer;              //系统返回登陆序列号(登陆成功返回新的序列号>0 , 退出登陆成功返回0),失败返回 -9
{
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@     设计时间      : 2002.1.21                                                 @
@     初始设计者    : 曾忠诚                                                    @
@     模块名称      :                                                           @
@     模块功能      : 本模块主要用于把大客户系统的操作历史写入数据库            @
@     输入          :操作模块,触发事件,登陆序列号,操作工号,操作说明        @
@     注意          :                                                          @
@      对于多窗体的(MDI)的模式中需要注意的是当用户还没有退出该窗体的时候,    @
@      不要重复登记该操作历史,需要把该窗体提到最前面显示出来,不进行操作登记   @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
}
Var
   QueryUserLogin  : TQuery ;   //用于生成序列号
   Query_oper_Log  : TQuery ;
   New_Seq         : Integer;
   Str             : String ;
   Bgn_time: string;//开始时间
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        //新增加一个操作历史记录
     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;
           //不知道为什么关闭后在数据库中无法存入,只有等到关闭窗口后才能存入
         Result  := New_Seq;     //登入登记成功 返回成功的代码
         GF_SaveAndGetSeq(EntryModule+EntryEvt,New_Seq);  //把登陆时候的ID号进行保存。
        except
          Result := -9 ;  //登入登记失败
        End;
      End
   Else
      Begin
        try
         Login_Seq := GF_SaveAndGetSeq(EntryModule+EntryEvt,-1);  //请求得到某一个模块的退出时间修改的id号
         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 ;  //退出登陆登记成功,返回传入的参数值
        except
         Result := -9 ;  //退出登陆登记失败
        End;
      End;
   QueryUserLogin.Free;
   Query_oper_Log.Free;
end;

function GF_SaveAndGetSeq(Form_Name : String ; NewSeq : Integer ) : integer ;
  {输入:  窗体的名称,获取历史记录登记的序列号
   处理: 对于新的序列号(NewSeq<>-1)写入注册表中\HKEY_LOCAL_MACHINE\SOFTWARE\Doone\VipSystem中,
          对于请求已经进行保存的需要得到序列号的时候(NewSeq=-1)根据FormName(窗体名称)找到相对应的登记序列号
   结果: 对于新的序列号的话,返回0 :保存成功  -9 : 返回失败
          对于请求得到序列号的时候,返回 序列号(>0): 请求成功 -9:请求失败
  }
var
  RegVar : TRegistry ;

begin

  RegVar := TRegistry.Create;
  RegVar.RootKey :=  HKEY_LOCAL_MACHINE ;
  RegVar.OpenKey(RegName,True);
  //把需要注册的内容写入到指定的注册表中,不存在的时候自动创建

  if NewSeq<>-1 then  //写入信息
    try
     RegVar.WriteInteger(Form_Name,NewSeq);
     Result := 0;  //写入成功
    except
     Result := -9; //写入失败
    End
  else  //读出信息
    try
      Result := RegVar.ReadInteger(Form_Name);
    except
      Result := -9;  //读取失败
    End;
  RegVar.Free;
  
end;

Function CpuType : TCpuType; ASSEMBLER; 
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//@                                                @
//@        用汇编来获取CPU的型号                   @
//@     arthur by zengzc 2001.11.19                @
//@                                                @
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Asm
   // 8086 CPU 检测
   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检测
   or bx, 0f000h
   push bx
   popf
   pushf
   pop ax
   and ax, 0f000h
   mov ax, cpu286
   jz @@End_CpuType
   // 386 CPU 检测
   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 检测
   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 检测
   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系统版本号                   @
//@     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的版本号

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -