📄 ucustommodule.pas
字号:
{*******************************************************
项目:离线式制卡系统
模块:自定义函数模块
描述:
版本:1.0
日期:
作者:刘进雄
邮箱: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 ................. 自定义光标
2. ReadRegKey ................... 读注册表键值
3. WriteRegKey .................. 写注册表键值
4. GetExePath ................... 取应用程序路径
5. GetParameter ................. 取配置文件参数
6. RebootExpires ................ 让重新启动失效
7. RebootRestore ................ 恢复重新启动功能
8. CloseExpires ................. 使窗口关闭功能失效
9. CloseRestore ................. 恢复窗口关闭功能
10. HideDesktop ................. 隐藏桌面图标
11. ShowDesktop ................. 显示桌面图标
12. ChangeWallPaper ............. 更改墙纸
13. myGetWindowsDirectory ....... 取Windows目录
14. myGetSystemDirectory ........ 取系统目录
15. myGetTempPath ............... 取临时路径
16. myGetLogicalDrives .......... 取逻辑驱动器
17. myGetUserName ............... 取用户名
18. myGetComputerName ........... 取计算机名
19. mySelectDirectory ........... 选择目录
20. myClearDocument ............. 清除开始菜单我的文档内容
21. SystemAbout ................. 调用系统关于对话框
22. SelectDir ................... 选择目录
23. HideFormOnTask .............. 在任务栏上隐藏窗口
24. ConvertBMPtoJPG ............. 转化BMP格式为JPG
25. ConvertJPGtoBMP ............. 转化JPG格式为BMP
26. Replacing ................... 替换某一字符串
27. SmallTOBig .................. 转化数字为大写中文(1 - 壹)
28. CreateShortCut .............. 建立快捷方式
29. myAddDocument ............... 增加文件到最近打开过的文档
30. GetFileIcon ................. 取得文件图标
31. GetCDROMNumber .............. 取CDROM序列号
32. SetCDAutoRun ................ 设置光驱是否自动运行
33. OpenCDROM ................... 打开光驱
34. CloseCDROM .................. 关闭光驱
35. GetDiskSizeAvail ............ 取磁盘所有字节数和剩余字节数
36. GetDiskSize ................. 取磁盘所有字节数和剩余字节数
37. SystemBarCall ............... 系统控制面板功能调用
38. GetUserNameAPI .............. 取用户名(API方式)
39. GetWindowsProductID ......... 取WINDOWS产品ID
40. HideTaskbar ................. 隐藏任务栏
41. ShowTaskbar ................. 显示任务栏
42. MakeTree .................... 获取目录树
43. CreateDsn ................... 建立DSN
44. CnToPY ...................... 转化中文为拼音首字母
45. AddIcoToIE .................. 增加应用程序图标到IE
46. SetVolume ................... 设置磁盘卷标
47. FormatFloppy ................ 格式化软盘
48. IsAudioCD ................... 判断光驱中是否为CD盘
49. PlayAudioCD ................. 播放CD盘
50. DiskInDrive ................. 判断驱动器是否就绪
51. CheckDriverType ............. 检查驱动器类型
52. IsFileInUse ................. 判断文件是否在使用
53. CopyDir ..................... 拷贝目录包含子目录
54. DeleteDir (No use) .......... 删除目录包含子目录
55. CreateTempFile .............. 建立临时文件
56. SearchFile .................. 寻找文件
57. GetProgramAssociation ....... 取得应用程序扩展
58. myGetFileTime ............... 取文件建立时间
59. SetFileDateTime ............. 设置文件时间
60. GetFileLastAccessTime ....... 取文件最后访问时间
61. CreateDirectory ............. 建立目录
62. ChangeDirectory ............. 改变目录
63. GetDirectory ................ 得到目录
64. SetCurrentDirectory ......... 设置当前目录
65. RenameDirOrFile ............. 更改目录或文件名
66. CreateMultiDir .............. 建立多级目录
67. DirExist .................... 判断目录是否存在
68. ChangeFileExtension ......... 更改文件扩展名
69. GetFileExtension ............ 取文件扩展名
70. FileCopy1 ................... 文件拷贝
71. FileCopy2 ................... 文件拷贝
72. FileCopy3 ................... 文件拷贝
73. SetFileAttribAPI ............ 设置文件属性(API方式)
74. SetFileAttrib ............... 设置文件属性
75. GetFilePath1 ................ 取得文件路径(有'\'结尾)
76. GetFilePath2 ................ 取得文件路径(没有'\'结尾)
77. CopyDelRenMovFile ........... 拷贝、删除、改名或移动文件
78. GetPortUsed ................. 得到已被使用串口列表
79. SetMediaAudioOff ............ 静音播放媒体文件
80. SetMediaAudioOn ............. 打开媒体播放文件声音
81. WaitExeFinish ............... 等待直到可执行文件执行完成
}
//_____________________________________________________________________//
// //
// 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -