?? ucustommodule.pas
字號:
{*******************************************************
項目:離線式制卡系統(tǒng)
模塊:自定義函數(shù)模塊
描述:
版本:1.0
日期:
作者:劉進(jìn)雄
郵箱:apollo@skyon.com.cn & ljx@skyon.com.cn
更新:
*******************************************************}
unit uCustomModule;
interface
uses
Windows, Messages, Classes, Graphics, Controls, Forms, SysUtils,
ExtCtrls, Dialogs, Buttons, Registry, FileCtrl, ShlObj, ShellAPI,
jpeg, ActiveX, ComObj, MMSystem, MPlayer, StdCtrls, LZExpand;
//_____________________________________________________________________//
// //
// Moudle index //
//_____________________________________________________________________//
{
1. CustomCursor ................. 自定義光標(biāo)
2. ReadRegKey ................... 讀注冊表鍵值
3. WriteRegKey .................. 寫注冊表鍵值
4. GetExePath ................... 取應(yīng)用程序路徑
5. GetParameter ................. 取配置文件參數(shù)
6. RebootExpires ................ 讓重新啟動失效
7. RebootRestore ................ 恢復(fù)重新啟動功能
8. CloseExpires ................. 使窗口關(guān)閉功能失效
9. CloseRestore ................. 恢復(fù)窗口關(guān)閉功能
10. HideDesktop ................. 隱藏桌面圖標(biāo)
11. ShowDesktop ................. 顯示桌面圖標(biāo)
12. ChangeWallPaper ............. 更改墻紙
13. myGetWindowsDirectory ....... 取Windows目錄
14. myGetSystemDirectory ........ 取系統(tǒng)目錄
15. myGetTempPath ............... 取臨時路徑
16. myGetLogicalDrives .......... 取邏輯驅(qū)動器
17. myGetUserName ............... 取用戶名
18. myGetComputerName ........... 取計算機(jī)名
19. mySelectDirectory ........... 選擇目錄
20. myClearDocument ............. 清除開始菜單我的文檔內(nèi)容
21. SystemAbout ................. 調(diào)用系統(tǒng)關(guān)于對話框
22. SelectDir ................... 選擇目錄
23. HideFormOnTask .............. 在任務(wù)欄上隱藏窗口
24. ConvertBMPtoJPG ............. 轉(zhuǎn)化BMP格式為JPG
25. ConvertJPGtoBMP ............. 轉(zhuǎn)化JPG格式為BMP
26. Replacing ................... 替換某一字符串
27. SmallTOBig .................. 轉(zhuǎn)化數(shù)字為大寫中文(1 - 壹)
28. CreateShortCut .............. 建立快捷方式
29. myAddDocument ............... 增加文件到最近打開過的文檔
30. GetFileIcon ................. 取得文件圖標(biāo)
31. GetCDROMNumber .............. 取CDROM序列號
32. SetCDAutoRun ................ 設(shè)置光驅(qū)是否自動運行
33. OpenCDROM ................... 打開光驅(qū)
34. CloseCDROM .................. 關(guān)閉光驅(qū)
35. GetDiskSizeAvail ............ 取磁盤所有字節(jié)數(shù)和剩余字節(jié)數(shù)
36. GetDiskSize ................. 取磁盤所有字節(jié)數(shù)和剩余字節(jié)數(shù)
37. SystemBarCall ............... 系統(tǒng)控制面板功能調(diào)用
38. GetUserNameAPI .............. 取用戶名(API方式)
39. GetWindowsProductID ......... 取WINDOWS產(chǎn)品ID
40. HideTaskbar ................. 隱藏任務(wù)欄
41. ShowTaskbar ................. 顯示任務(wù)欄
42. MakeTree .................... 獲取目錄樹
43. CreateDsn ................... 建立DSN
44. CnToPY ...................... 轉(zhuǎn)化中文為拼音首字母
45. AddIcoToIE .................. 增加應(yīng)用程序圖標(biāo)到IE
46. SetVolume ................... 設(shè)置磁盤卷標(biāo)
47. FormatFloppy ................ 格式化軟盤
48. IsAudioCD ................... 判斷光驅(qū)中是否為CD盤
49. PlayAudioCD ................. 播放CD盤
50. DiskInDrive ................. 判斷驅(qū)動器是否就緒
51. CheckDriverType ............. 檢查驅(qū)動器類型
52. IsFileInUse ................. 判斷文件是否在使用
53. CopyDir ..................... 拷貝目錄包含子目錄
54. DeleteDir (No use) .......... 刪除目錄包含子目錄
55. CreateTempFile .............. 建立臨時文件
56. SearchFile .................. 尋找文件
57. GetProgramAssociation ....... 取得應(yīng)用程序擴(kuò)展
58. myGetFileTime ............... 取文件建立時間
59. SetFileDateTime ............. 設(shè)置文件時間
60. GetFileLastAccessTime ....... 取文件最后訪問時間
61. CreateDirectory ............. 建立目錄
62. ChangeDirectory ............. 改變目錄
63. GetDirectory ................ 得到目錄
64. SetCurrentDirectory ......... 設(shè)置當(dāng)前目錄
65. RenameDirOrFile ............. 更改目錄或文件名
66. CreateMultiDir .............. 建立多級目錄
67. DirExist .................... 判斷目錄是否存在
68. ChangeFileExtension ......... 更改文件擴(kuò)展名
69. GetFileExtension ............ 取文件擴(kuò)展名
70. FileCopy1 ................... 文件拷貝
71. FileCopy2 ................... 文件拷貝
72. FileCopy3 ................... 文件拷貝
73. SetFileAttribAPI ............ 設(shè)置文件屬性(API方式)
74. SetFileAttrib ............... 設(shè)置文件屬性
75. GetFilePath1 ................ 取得文件路徑(有'\'結(jié)尾)
76. GetFilePath2 ................ 取得文件路徑(沒有'\'結(jié)尾)
77. CopyDelRenMovFile ........... 拷貝、刪除、改名或移動文件
78. GetPortUsed ................. 得到已被使用串口列表
79. SetMediaAudioOff ............ 靜音播放媒體文件
80. SetMediaAudioOn ............. 打開媒體播放文件聲音
81. WaitExeFinish ............... 等待直到可執(zhí)行文件執(zhí)行完成
}
//_____________________________________________________________________//
// //
// Declare function and procedure //
//_____________________________________________________________________//
//-------------------------------//
//1. Custom application cursors
//-------------------------------//
{
Function:
The procedure will use custom cursors replace default cursors
Parameter:
objControl: Object name
iPosition: The cursors position which want to change
iMode: Object type
sFilePath: New cursors file path will be loading
Return value:
None
Example:
CustomCursor(frmMain, 1, 1, 'C:\test1.ico');
CustomCursor(imgPhoto, 2, 1, 'C:\test2.ico');
CustomCursor(pnlRecord, 3, 1, 'C:\test3.ico');
}
procedure CustomCursor(const objControl: TObject;const iPosition,
iMode: integer;const sFilePath: string);
//-------------------------------//
//2. Read key from register
//-------------------------------//
{
Function:
The procedure's function is read register key value
Parameter:
iMode: Read value type
sPath: Key path
sKeyName: Key name
Return value:
The key value
Example:
ReadRegKey(1, '\Software\Microsoft\Windows\', 'Text');
ReadRegKey(2, '\Software\Microsoft\Windows\', 'Numeric');
}
function ReadRegKey(const iMode: integer; const sPath,
sKeyName: string): string;
//-------------------------------//
//3. Write key to regisiter
//-------------------------------//
{
Function:
Use the function to write the key and value into registry
Parameter:
iMode: Write value type
sPath: Key path
sKeyName: Key name
sKeyValue: Key value which will been written
Return value:
Write result if success
Example:
WriteRegKey(1, '\Software\Microsoft\Windows\', 'Text', 'It's a test.');
WriteRegKey(2, '\Software\Microsoft\Windows\', 'Numeric', '1');
}
function WriteRegKey(const iMode: integer; const sPath, sKeyName,
sKeyValue: string): Boolean;
//-------------------------------//
//4. Get execute file path
//-------------------------------//
{
Function:
Obtain main execute file path
Parameter:
Null
Return value:
Execute file path
Example:
GetExePath();
}
function GetExePath(): string;
//-------------------------------//
//5. Get configure file parameter
//-------------------------------//
{
Function:
Get execute file configure parameter
Parameter:
FileName: Configure file name
Return value:
Configure parameter value
Example:
GetParameter('C:\Configure.ini');
}
function GetParameter(const FileName: string): WideString;
//-------------------------------//
//6. Set reboot expires(Alt+Ctrl+Del)
//-------------------------------//
{
Function:
Set computer reboot key expires
Parameter:
Null
Return value:
None
Example:
RebootExpires();
}
procedure RebootExpires();
//-------------------------------//
//7. Set reboot enabled restore(Alt+Ctrl+Del)
//-------------------------------//
{
Function:
Restore reboot enabled
Parameter:
Null
Return value:
None
Example:
RebootRestore();
}
procedure RebootRestore();
//-------------------------------//
//8. Set close form expires
//-------------------------------//
{
Function:
Set close form key expires
Parameter:
Null
Return value:
None
Example:
CloseExpires();
}
procedure CloseExpires();
//-------------------------------//
//9. Set close form enabled restore
//-------------------------------//
{
Function:
Restore close form enabled
Parameter:
Null
Return value:
None
Example:
CloseRestore();
}
procedure CloseRestore();
//-------------------------------//
//10. Hide desktop's icons
//-------------------------------//
{
Function:
All of icons on desktop will been hidden
Parameter:
Null
Return value:
None
Example:
HideDesktop();
}
procedure HideDesktop();
//-------------------------------//
//11. Show desktop's items
//-------------------------------//
{
Function:
All of desktop's icons will been shown
Parameter:
Null
Return value:
None
Example:
ShowDesktop();
}
procedure ShowDesktop();
//-------------------------------//
//12. Change desktop wall paper
//-------------------------------//
{
Function:
Set desktop wall paper use user refer to
Parameter:
sPath: Use this parameter to load a picture as wall paper
Return value:
false: Fail
true: Success
Example:
ChangeWallPaper('C:\wallpaper.bmp');
}
function ChangeWallPaper(const sPath: string): Boolean;
//-------------------------------//
//13. Get windows directory
//-------------------------------//
{
Function:
Get windows directory
Parameter:
Null
Return value:
Windows directory like 'C:\WINNT' or 'C:\Windows' etc.
Example:
myGetWindowsDirectory();
}
function myGetWindowsDirectory(): string;
//-------------------------------//
//14. Get windows system directory
//-------------------------------//
{
Function:
Get windows system directory
Parameter:
Null
Return value:
Windows system directory as 'C:\Winnt\System32'
Example:
myGetSystemDirectory()
}
function myGetSystemDirectory(): string;
//-------------------------------//
//15. Get system temperory directory
//-------------------------------//
{
Function:
Get system temperory directory
Parameter:
Null
Return value:
Temperory path
Example:
myGetTempPath();
}
function myGetTempPath(): string;
//-------------------------------//
//16. Get logical drives
//-------------------------------//
{
Function:
Use the function to get logical drives
Parameter:
Null
Return value:
Drives value like 'ACD'
Example:
myGetLogicalDrives()
}
function myGetLogicalDrives(): string;
//-------------------------------//
//17. Get login user name
//-------------------------------//
{
Function:
Get login user name
Parameter:
Null
Return value:
User name which to login computer
Example:
myGetUserName()
}
function myGetUserName(): string;
//-------------------------------//
//18. Get computer name
//-------------------------------//
{
Function:
Get computer name
Parameter:
Null
Return value:
Computer name
Example:
myGetComputerName()
}
function myGetComputerName(): string;
//-------------------------------//
//19. Select directory
//-------------------------------//
{
Function:
Select directory where pointer to
Parameter:
sDescription: The text show for user
sPath: Start position
Return value:
What directory to been selected
Example:
mySelectDirectory('Please select directory:', 'C:\');
}
function mySelectDirectory(const sDescription, sPath: string): string;
//-------------------------------//
//20. Clear document
//-------------------------------//
{
Function:
Clear document that recently access
Parameter:
Null
Return value:
None
Example:
myClearDocument()
}
procedure myClearDocument();
//-------------------------------//
//21. Call system about dialog
//-------------------------------//
{
Function:
Call system about dialog
Parameter:
sTitle: Infomation title
sContent: Infomation content
Return value:
None
Example:
SystemAbout('POS system', 'Use the system for check out');
}
procedure SystemAbout(const sTitle, sContent: string);
//-------------------------------//
//22. Select directory or file
//-------------------------------//
{
Function:
Select directory or file
Parameter:
iMode: Meant select directory and file or only select directory
Return value:
Directory name or file name
Example:
SelectDir(1, 'Please select file:');
SelectDir(2, 'Please select directory:');
}
function SelectDir(const iMode: integer; const sInfo: string): string;
//-------------------------------//
//23. Hide form on task
//-------------------------------//
{
Function:
Hide form on task
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -