1.GetComputerName - 获取计算机名称
var arr:array[0..MAX_COMPUTERNAME_LENGTH]of
char;
d: DWORD;
begin
d := SizeOf(arr);
GetComputerName(arr, d);
ShowMessage(arr);
end;
2.GetCursorPos 获取的是鼠标相对与屏幕的位置
var
ps: TPoint;
str: string;
begin
GetCursorPos(ps);
str := Format('%d,%d',[ps.X,ps.Y]);
ShowMessage(str);
end;
3. SetComputerName - 更改计算机名称
s := 'NewName';
if SetComputerName(PChar(s))then
ShowMessage(s)
{改名成功后, 重新启动计算机后才有效}
4.SetCursorPos - 设置鼠标指针位置
SetCursorPos(0,0);{鼠标移动到左上角}
5.GetTickCount: DWORD;{无参数; 返回系统已启动的时间(毫秒)}
t := GetTickCount;
ShowMessage(IntToStr(t));
6.GetUserName - 获取当前用户名
var
arr: array[0..254]of
Char;
d: DWORD;
begin
d := SizeOf(arr);
GetUserName(arr, d);
ShowMessage(arr);
{wy}
end;
7.GetVersion - 获取系统版本号
d := GetVersion;
8.GetVersionEx - 获取系统版本详细信息
var
OsInfo: TOSVersionInfo;
const s ='主编号:
%d' + sLineBreak +
'次编号: %d' + sLineBreak +
'建立编号: %d' + sLineBreak +
'作业平台: %d' + sLineBreak +
'更多说明: %s';
begin
OsInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);{先根据大小要内存}
GetVersionEx(OsInfo);
ShowMessage(Format(s, [OsInfo.dwMajorVersion, OsInfo.dwMinorVersion, OsInfo.dwBuildNumber, OsInfo.dwPlatformId, OsInfo.szCSDVersion]));
end;
9.MessageBeep - 播放一个系统声音
10.GetSystemInfo - 获取系统信息
//TSystemInfo是 _SYSTEM_INFO结构的重定义:
_SYSTEM_INFO =record
case Integerof
0: (
dwOemId: DWORD);{返回计算机标识符,已废弃}
1: (
wProcessorArchitecture: Word; {处理器的体系结构}
wReserved: Word; {保留}
dwPageSize: DWORD; {分页大小}
lpMinimumApplicationAddress: Pointer;{最小寻址空间}
lpMaximumApplicationAddress: Pointer;{最大寻址空间}
dwActiveProcessorMask: DWORD; {处理器掩码; 0..31 表示不同的处理器}
dwNumberOfProcessors: DWORD; {处理器数目}
dwProcessorType: DWORD; {处理器类型}
dwAllocationGranularity: DWORD; {虚拟内存空间的粒度}
wProcessorLevel: Word; {处理器等级}
wProcessorRevision: Word); {处理器版本}
end;
11.GetKeyboardType - 获取键盘的类型信息
GetKeyboardType(
nTypeFlag: Integer
{0:键盘类型; 1:键盘子类型; 2:功能键数量}
): Integer;
12.GetDiskFreeSpace - 获取磁盘组织与容量信息
var
d1,d2,d3,d4: DWORD;
begin
GetDiskFreeSpace('C:',d1,d2,d3,d4); {以下只是显示}
Memo1.Clear;
with Memo1.Linesdo
begin
Add(Format('一个簇内的扇区数: %d',[d1]));
Add(Format('一个扇区内的字节数: %d',[d2]));
Add(Format('剩余簇数: %d',[d3]));
Add(Format('总簇数: %d',[d4]));
Add(Format('剩余空间: %f GB',[d3/1024/1024/1024*d2*d1]));
Add(Format('总空间: %f GB',[d4/1024/1024/1024*d2*d1]));
end;
13.GetDiskFreeSpaceEx - 获取磁盘容量信息
GetDiskFreeSpaceEx('C:',d1,d2,@d3);
Memo1.Clear;
with Memo1.Linesdo
begin
Add(Format('可用空间: %f GB',[d1/1024/1024/1024]));
Add(Format('总空间: %f GB',[d2/1024/1024/1024]));
Add(Format('剩余空间: %f GB',[d3/1024/1024/1024]));
end;
14.GetDriveType - 获取磁盘类型
c := GetDriveType('C:'); {磁盘根目录}
ShowMessage(IntToStr(c));
{3; 说明是本地硬盘}
15.GetVolumeInformation - 读取文件系统信息
RootPath := 'C:\';
GetVolumeInformation( RootPath, VolName,
255, @SerialNumber, MaxCLength, FileSysFlag, FileSysName, 255
);
Memo1.Clear;
with Memo1.Linesdo
begin
Add(Format('磁盘驱动器代码字符串:'+#9#9
+'%s',[RootPath]));
Add(Format('磁盘驱动器卷标名称:'+#9#9
+'%s',[VolName]));
Add(Format('磁盘驱动器卷标序列号:'+#9#9
+'%s',[IntToHex(SerialNumber,8)]));
Add(Format('系统允许的最大文件名长度:'+#9
+'%d',[MaxCLength]));
Add(Format('文件系统标识:'+#9#9#9
+'%d',[FileSysFlag]));
Add(Format('文件系统名称:'+#9#9#9
+'%s',[FileSysName]));
end;
16.GetLogicalDrives - 判断系统中存在的逻辑驱动器
Drives := GetLogicalDrives; Memo1.Clear;
for i :=0to25do{最多
26 个字母都用上}
if LongBool(Drivesand
($0001shl
i)) = Truethen
Memo1.Lines.Add(Char(Ord('A')+i) +':\');
17.GetDoubleClickTime: UINT;
{无参数; 返回鼠标双击间隔时间, 单位是毫秒}
SetDoubleClickTime( Interval: UINT {依毫秒为单位的时间数}):
BOOL;
c := GetDoubleClickTime;
SetDoubleClickTime(499);
18.SwapMouseButton - 交换鼠标左右键的功能
SwapMouseButton(
fSwap: BOOL {True: 交换; False: 恢复}
): BOOL;
19.GetLocalTime、SetLocalTime、SetSystemTime - 获取与设置系统时间
GetSystemTime(T);
20.GetSystemPowerStatus - 获取系统电源状态的信息
var Power: TSystemPowerStatus;
begin
GetSystemPowerStatus(Power);
21.GetKeyNameText - 根据键盘消息获取按键名称
procedure TForm1.MyMsg(var
msg: TWMKeyDown);
var
buf: array[0..31]of
Char;
rect: TRect; str:
string;
begin {获取}
GetKeyNameText(msg.KeyData, buf, Length(buf));
{画出来}
str := buf; rect := ClientRect;
Canvas.FillRect(rect);
Canvas.TextRect(rect, str, [tfSingleLine, tfCenter, tfVerticalCenter]);
inherited;end;
22.更换桌面壁纸
var
BmpPath: PChar;
begin
BmpPath := 'C:\Temp\Test.bmp';
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, BmpPath, SPIF_UPDATEINIFILE);
end;
23.输入光标相关的函数[1]
CreateCaret {建立}
DestroyCaret {释放}
ShowCaret {显示} HideCaret {隐藏}
SetCaretPos {设置位置} GetCaretPos {获取位置}
SetCaretBlinkTime {设置间隔时间}
GetCaretBlinkTime {获取间隔时间}
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
CreateCaret(Handle,
0,0,20);
SetCaretPos(X, Y);
ShowCaret(Handle);
end;