?? commfun.pas.svn-base
字號:
unit CommFun;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, CommCtrl, DBGrids, DB, DBTables, menus, Registry,
Wwintl, Buttons, Extctrls, dbctrls, Wait, SYSDATA, ComObj, ActiveX,
dxDBGrid, wwfltdlg, wwDialog, Wwlocate, ADODB, dxTL, dxDBCtrl, dxDBTL, IniFiles,
ShellApi, WinInet, atScript, atPascal, ActnList, StrUtils, IdGlobal, DateUtils,
winsock, fr_Class, FR_DBSet, HwSelReport, ShlObj;
type
//硬盤ID號
TSrbIoControl = packed record
HeaderLength: ULONG;
Signature: array[0..7] of Char;
Timeout: ULONG;
ControlCode: ULONG;
ReturnCode: ULONG;
Length: ULONG;
end;
SRB_IO_CONTROL = TSrbIoControl;
PSrbIoControl = ^TSrbIoControl;
TIDERegs = packed record
bFeaturesReg: Byte; // Used for specifying SMART "commands".
bSectorCountReg: Byte; // IDE sector count register
bSectorNumberReg: Byte; // IDE sector number register
bCylLowReg: Byte; // IDE low order cylinder value
bCylHighReg: Byte; // IDE high order cylinder value
bDriveHeadReg: Byte; // IDE drive/head register
bCommandReg: Byte; // Actual IDE command.
bReserved: Byte; // reserved. Must be zero.
end;
IDEREGS = TIDERegs;
PIDERegs = ^TIDERegs;
TSendCmdInParams = packed record
cBufferSize: DWORD;
irDriveRegs: TIDERegs;
bDriveNumber: Byte;
bReserved: array[0..2] of Byte;
dwReserved: array[0..3] of DWORD;
bBuffer: array[0..0] of Byte;
end;
SENDCMDINPARAMS = TSendCmdInParams;
PSendCmdInParams = ^TSendCmdInParams;
TIdSector = packed record
wGenConfig: Word;
wNumCyls: Word;
wReserved: Word;
wNumHeads: Word;
wBytesPerTrack: Word;
wBytesPerSector: Word;
wSectorsPerTrack: Word;
wVendorUnique: array[0..2] of Word;
sSerialNumber: array[0..19] of Char;
wBufferType: Word;
wBufferSize: Word;
wECCSize: Word;
sFirmwareRev: array[0..7] of Char;
sModelNumber: array[0..39] of Char;
wMoreVendorUnique: Word;
wDoubleWordIO: Word;
wCapabilities: Word;
wReserved1: Word;
wPIOTiming: Word;
wDMATiming: Word;
wBS: Word;
wNumCurrentCyls: Word;
wNumCurrentHeads: Word;
wNumCurrentSectorsPerTrack: Word;
ulCurrentSectorCapacity: ULONG;
wMultSectorStuff: Word;
ulTotalAddressableSectors: ULONG;
wSingleWordDMA: Word;
wMultiWordDMA: Word;
bReserved: array[0..127] of Byte;
end;
PIdSector = ^TIdSector;
TFileInfo = packed record
CommpanyName: string;
FileDescription: string;
FileVersion: string;
InternalName: string;
LegalCopyright: string;
LegalTrademarks: string;
OriginalFileName: string;
ProductName: string;
ProductVersion: string;
Comments: string;
VsFixedFileInfo:VS_FIXEDFILEINFO;
UserDefineValue:string;
end;
{
PFixedFileInfo = ^TFixedFileInfo;
TFixedFileInfo = record
dwSignature : DWORD;
dwStrucVersion : DWORD;
wFileVersionMS : WORD; // 次版本號
wFileVersionLS : WORD; // 主版本號
wProductVersionMS : WORD; // 建立次數(build)
wProductVersionLS : WORD; // 發行次數(release)
dwFileFlagsMask : DWORD;
dwFileFlags : DWORD;
dwFileOS : DWORD;
dwFileType : DWORD;
dwFileSubtype : DWORD;
dwFileDateMS : DWORD;
dwFileDateLS : DWORD;
end; // TFixedFileInfo
}
DWORD_PTR = ^DWORD;
PCustomerInfo = ^TCustomerInfo;
TCustomerInfo = record
CustNo : Integer; //客戶電腦編號
CustCode : string; //客戶編號
CustName : string; //客戶名稱
CustShort : string; //客戶簡稱
CustAddress : string; //交貨地址
CustEmail : string; //客戶電郵
CustContact : string; //聯系人名
CustPosition : string; //職務名稱
CustPhone : string; //電話號碼
CustFax : string; //傳真號碼
end;
PCustItemInfo = ^TCustItemInfo;
TCustItemInfo = record
Reference:String; //控制器號
InstallDate:TDateTime; //安裝日期
StartDate:TDateTime; //免費保養開始日期
EndDate:TDateTime; //免費保養結束日期
FromDate:TDateTime; //收費保養開始日期
ToDate:TDateTime; //收費保養結束日期
end;
POrderInfo = ^TOrderInfo;
TOrderInfo = record
CustNo : Integer; //客戶編號
SaleNo : Integer; //銷售員號
RegionNo : Integer; //交貨地區
OrderDate : TDateTime; //定單日期
CurrNo : Integer; //幣別編號
ItemNo : Integer; //料品編號
UnitNo : Integer; //計量單位
OrderQty : Double; //定單數量
LineSumAmt : Double; //定單行銷售總額
LineDisAmt : Double; //定單行總折扣額
ChargeAmt : Double; //特殊費用
OrdDisAmt : Double; //定單總折扣額
IsSumDis : Boolean; //總額折扣
IsOrderDis : Boolean; //定單折扣
InvAmount : Boolean; //發票金額
end;
PPriceInfo = ^TPriceInfo;
TPriceInfo = record
StdPrice : Double; //標準價格
OrderAmt : Double; //定單金額
OrdPrice : Double; //折后價格
DisRate : Double; //折扣比率
DisAmt : Double; //折扣金額
NetAmt : Double; //折后金額
TaxRate: Double; //銷售稅率
TaxAmount: Double; //銷售稅額
Amount : Double; //總額
IsBySum : Boolean; //是否依據總額計價
end;
PItemInfo = ^TItemInfo;
TItemInfo = record
ItemNo : Integer; //料品電腦編號
ItemID : String; //料品編號
ItemName : String; //料品名稱
ItemSpec : String; //規格型號
UnitNo : Integer; //計量單位電腦編號
UnitID : String; //計量單位編號
UnitName : String; //計量單位名稱
ItemNum:double;
OrderNo : String; //來源單號
LineNo : Integer; //來源行號
OtherNo:string; //其他編號
COrder:string; //客戶訂單編號
end;
PSpecInfo = ^TSpecInfo;
TSpecInfo = record
AType : Integer;
AFromDate : TDateTime;
AToDate : TDateTime;
ACurr : String;
AIsSum : Boolean;
AItemNo : Integer;
AItemClass : Integer;
ACustNo : Integer;
ACustClass : Integer;
ACustGrade : Integer;
ASaleNo : Integer;
ASaleGrade : Integer;
ARegionNo : Integer;
AIsSame : Boolean;
ARange : Integer;
AAmtType : Integer;
end;
PLangInfo = ^TLangInfo;
TLangInfo = record
AFormName:string;
AComponentName:string;
AComponentCaption:string;
APrefix:string;
APostfix:string;
ACode:string;
end;
const
dwCookie :DWORD = 0;
IDE_ID_FUNCTION = $EC;
IDENTIFY_BUFFER_SIZE = 512;
DFP_RECEIVE_DRIVE_DATA = $0007C088;
IOCTL_SCSI_MINIPORT = $0004D008;
IOCTL_SCSI_MINIPORT_IDENTIFY = $001B0501;
DataSize = sizeof(TSendCmdInParams) - 1 + IDENTIFY_BUFFER_SIZE;
BufferSize = SizeOf(SRB_IO_CONTROL) + DataSize;
W9xBufferSize = IDENTIFY_BUFFER_SIZE + 16;
var
ADataSetName:string; //數據集名稱
ARecord:array of Variant;
//如果對話框被打開,則在指定時間后關閉,并在標題欄進行提示
nWndCount: Integer = 0;
SavWnds, SavWnds2: array of THandle;
hDlgWnd: THandle = 0;
hTimerk: Integer = 0;
nTimerTick: Integer = 0;
nLastTrk: Integer = 0;
nDoHint: Integer = 0;
nCapCt: Integer = 0;
nSavCapt: String = '';
fTimer1: TTimer = nil;
//設置全局變量
AUserID:Integer;
AUserName:string;
ASuper:Boolean; //超級用戶
ACompanyID:string;
ACompanyName:string;
ALoginDate:TDateTime;
ALogoutDate:TDateTime;
AProgramID:string;
AHostID:string;
AServerName:string; //服務器名稱
AFontName:string;
ACharset:string; //字符集
AKeyColor:TColor; //關鍵字段字體顏色
AKeyStyle:TFontStyles; //關鍵字段字體類型 [fsBold],[fsItalic],[fsUnderline]
ADateFormat:array[0..11] of string; //日期格式
AQtyFormat:array[0..5] of string; //數量格式
APriceFormat:array[0..5] of string; //單價格式
AAmountFormat:array[0..5] of string; //金額格式
ARateFormat:array[0..5] of string; //匯率格式
ANegaFormat:array[0..1] of string; //負數格式
ANegaColor:TColor; //負數字體顏色
AAlterTime:Integer; //預警時間間隔(秒)
ALanguageID:integer; //語言編號(2052=簡體中文,1028=繁體中文,1033=英文)
ADemoFlag:Boolean; //True=演示版,False=正式版
APackageHandle:TStringList;
AContainsUnit:TStringList; //包文件中所包含的單元文件
AImgHandle:THandle;
ARegPath:string; //注冊表路徑
AFileName:string; //數據庫文件
AHandle:THandle;
ALangTable:string; //語言表
AHelpFile:string; //幫助文件
ADatabase:Integer; //0=Access, 1=SQL Server
HHControlInstance:THandle=0;
HtmlHelpA:function( hwndCaller:HWND; pszFile:PChar; uCommand:UINT; dwData:DWORD_PTR ):HWND;stdcall;
AStartTime:Double; //開始時間
ARunTime:Double; //執行時間
ASystemDate:array[0..9] of Char; //系統日期格式
ASystemPath:string; //系統路徑
AVerPath:string; //版本路徑
AIsSaveReg:Boolean; //是否保存界面信息到注冊表
AUpdateMain:Boolean; //是否更新程序 Ture=更新
AOEM:Boolean; //是否OEM版本 如果是OEM版本則幫助菜單中的與浩暉公司相關的菜單不顯示
AIsExit:Boolean; //直接退出系統
AModule:string; //模塊編號
AStatusNo:String; //已完成數量統計包含的狀態
AByTotal:string; //按照“申報日期”統計任務計劃的總數量
AByFinish:string; //按照“實際完成日期”統計任務計劃的完成數量
ARegUsers:Integer; //注冊用戶總數量
AVersion:string; //版本號
AHome:string; //官方網站
AEmail:string; //作者郵箱
ACurrNo:Integer; //本位幣號
ACurrID,ACurrName:string; //本位幣=幣別編號,本位幣=幣別名稱
AReportTitle:string; //報表名稱
AIsUpgrade:Boolean; //在線升級中
arXlsBegin: array[0..5] of Word = ($809, 8, 0, $10, 0, 0);
arXlsEnd: array[0..1] of Word = ($0A, 00);
arXlsString: array[0..5] of Word = ($204, 0, 0, 0, 0, 0);
arXlsNumber: array[0..4] of Word = ($203, 14, 0, 0, 0);
arXlsInteger: array[0..4] of Word = ($27E, 10, 0, 0, 0);
arXlsBlank: array[0..4] of Word = ($201, 6, 0, 0, $17);
ADisableColor:TColor=$00DDDDDD; //編輯柜失效時的顏色
AEnableColor:TColor=clWindow; //編輯柜有效時的顏色
AFormColor:TColor=clBtnFace; //窗口的顏色
//開啟窗體函數
procedure OpenForm(InstanceClass: TComponentClass; var Reference);
//開啟MDICHILD子窗體過程
procedure OpenChildForm(AFormClass:TFormClass;AForm:TComponent);
//錯誤信息顯示
function ShowMsg(AMsg:string;AType:Integer=0):Integer;
//顯示確認對話框
function ShowDialog(AMsg:string;AType:Integer=0;DEFBUTTON:Integer=MB_DEFBUTTON2):Integer;
//防止程序執行兩次 注意主窗體的CAPTION不能和APPLICATION。TITLE相同
procedure CheckInstance(AProgram:string);
//創建新的數據庫別名
procedure NewAlias(AliasName:string);
//復制記錄
procedure CopyRecord(ADataSet:TDataSet);
//粘貼記錄
procedure PasteRecord(ADataSet:TDataSet);
//字符串加密函數
function Encrypt(AStr:String):String;
//字符串解密函數
function Decrypt(AStr:String):String;
//取得某月的第一天的日期
function GetMonthFirstDate(ADate:TDate):TDate;
//取得某月的最后一天的日期
function GetMonthEndDate(ADate:TDate):TDate;
//取得上月的第一天的日期
function GetLastMonthFirstDate(ADate:TDate):TDate;
//取得上月的最后一天的日期
function GetLastMonthEndDate(ADate:TDate):TDate;
//取得本季的第一天的日期
function GetSeasonFirstDate(ADate:TDate):TDate;
//取得本季的最后一天的日期
function GetSeasonEndDate(ADate:TDate):TDate;
//取得上季的第一天的日期
function GetLastSeasonFirstDate(ADate:TDate):TDate;
//取得上季的最后一天的日期
function GetLastSeasonEndDate(ADate:TDate):TDate;
//取得本年的第一天的日期
function GetYearFirstDate(ADate:TDate):TDate;
//取得本年的最后一天的日期
function GetYearEndDate(ADate:TDate):TDate;
//取得上年的第一天的日期
function GetLastYearFirstDate(ADate:TDate):TDate;
//取得上年的最后一天的日期
function GetLastYearEndDate(ADate:TDate):TDate;
//取得上年同期
function GetLastYearSameDate(ADate:TDate):TDate;
//檢查輸入是否數字
procedure ValidInteger(Sender: TObject; var Key: Char);
//檢查輸入是否浮點數
procedure ValidFloat(Sender: TObject; var Key: Char);
//計算注冊碼
function Registered(AHardWareNo,AProduct:string):string;
//取得本機的名稱
function ComputerName:string;
//取得報表名稱
function GetReportName(ARepName:string):string;
//取硬盤序列號
function GetHDSerialNumber:String;
//轉換"N"為人民幣大寫
function Money_convert(N:Double):String;
//取得數據庫中的字符串
function GetDBString(ID:String;AFlag:Integer=1):String;
//動態載入Package
function LoadPack(APackName:String):Boolean;
//創建Package中的Form
function CreateFormInPackage(AFormName:string;AParent:TPanel):TForm; overload;
//創建Package中的Form
function CreateFormInPackage(AFormName:string;AFlag:Boolean):Integer; overload;
//取系統參數
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -