关于Windows API控制的几个小问题,请各位师兄来指点一下小弟..(200分)

  • 主题发起人 主题发起人 菜鸟黄
  • 开始时间 开始时间
应该是这个:<br>procedure TForm1.Button7Click(Sender: TObject);<br>var<br> &nbsp;mems:_MEMORYSTATUS;<br> &nbsp;m,n,i,A:integer;<br>begin<br> &nbsp; Memo1.Clear ;<br> &nbsp; GlobalMemoryStatus(mems);<br> &nbsp; mems.dwLength:=sizeof(mems);<br> &nbsp; m:=MemS.dwTotalPhys div 1024;<br> &nbsp; n:=MemS.dwAvailPhys div 1024;<br> &nbsp; A:=m-n;<br> &nbsp; i:=(n * 100)div m;<br> &nbsp; Memo1.Lines.Add('可用内存百分率:'+inttostr(i)+' %'+','+'可用内存:'+inttostr(n)+'k'+','+'总内存:'+inttostr(m)+'k'+','+'已用内存:'+inttostr(A) +'k');<br>end;
 
 检测CPU的型号 <br>--------------------------------------------------------------------------------<br>Unit CPUid; <br><br>Interface <br><br>Type <br><br>TCpuType = (cpu8086, cpu286, cpu386, cpu486, cpuPentium); <br><br>Function CpuType : TCpuType; <br>Function CpuTypeString : String; <br><br>Implementation <br><br>Uses <br>SysUtils; <br><br>Function CpuType : TCpuType; ASSEMBLER; <br>Asm <br>// 8086 CPU 检测<br>push ds <br>pushf <br>pop bx <br>mov ax, 0fffh <br>and ax, bx <br>push ax <br>popf <br>pushf <br>pop ax <br>and ax, 0f000h <br>cmp ax, 0f000h <br>mov ax, cpu8086 <br>je @@End_CpuType <br><br>// 80286 CPU检测 <br><br>or bx, 0f000h <br>push bx <br>popf <br>pushf <br>pop ax <br>and ax, 0f000h <br>mov ax, cpu286 <br>jz @@End_CpuType <br><br>// 386 CPU 检测<br><br>db 66h <br>pushf <br>db 66h <br>pop ax <br>db 66h <br>mov cx, ax <br>db 66h <br>xor ax, 0h <br>dw 0004h <br>db 66h <br>push ax <br>db 66h <br>popf <br>db 66h <br>pushf <br>db 66h <br>pop ax <br>db 66h <br>xor ax, cx <br>mov ax, cpu386 <br>je @@End_CpuType <br><br>// 486 CPU 检测<br><br>db 66h <br>pushf <br>db 66h <br>pop ax <br>db 66h <br>mov cx, ax <br>db 66h <br>xor ax, 0h <br>dw 0020h <br>db 66h <br>push ax <br>db 66h <br>popf <br>db 66h <br>pushf <br>db 66h <br>pop ax <br>db 66h <br>xor ax, cx <br>mov ax, cpu486 <br>je @@End_CpuType <br><br>// Pentium CPU 检测<br><br>db 66h <br>mov ax, 1 <br>dw 0 <br>db 66h <br>db 0Fh <br>db 0a2h <br>db 66h <br>and ax, 0F00H <br>dw 0 <br>db 66h <br>shr ax, 8 <br>sub ax, 1 <br><br>@@End_CpuType: <br><br>pop ds <br><br>End; <br><br>Function CpuTypeString : String; <br><br>Var <br><br>Kind : TCpuType; <br><br>Begin <br><br>Kind := CpuType; <br><br>Case Kind Of <br><br>cpu8086 : Result := '8086'; <br>cpu286 : Result := '286'; <br>cpu386 : Result := '386'; <br>cpu486 : Result := '486'; <br>cpuPentium : Result := 'Pentium'; <br><br>Else Result := Format ('P%d', [Ord (kind)]); <br><br>End; <br><br>End; <br><br>End.
 
to 网中戏~<br>谢谢师兄的支持有,以后多交流~我的Q号在上面有
 
我的笔记里的资料是以前,硬盘可能最大只支持到2G,再大了就不准了,内存也有一定的限制。
 
获取内存信息用我的上面的方法是非常准的~你可以试一下,把原来不准的代码更换掉~呵呵
 
to happycyp师兄你可不可以现在把获取磁盘的完善一下啊
 
procedure TForm1.Button1Click(Sender: TObject);<br>var<br> &nbsp;lpFreeBytesAvailableToCaller:int64;<br> &nbsp;lpTotalNumberOfBytes:int64;<br> &nbsp;lpTotalNumberOfFreeBytes : TLargeInteger;<br>begin<br> &nbsp;if GetDiskFreeSpaceEx('C:/', lpFreeBytesAvailableToCaller,<br>lpTotalNumberOfBytes, @lpTotalNumberOfFreeBytes) then<br> &nbsp;begin<br> &nbsp; &nbsp;showmessage(inttostr(lpFreeBytesAvailableToCaller div 1024 div 1024));<br>///或showmessage(inttostr(lpTotalNumberOfFreeBytes));<br> &nbsp;end;<br>end;<br>这个准了。用GetDiskFreeSpaceEx()函数,getdiskfreespace()支持空间有上限,好像是2G。
 
楼主去下载一个DFW的离线资料,这些问题稍微查找一下都可以解决了。<br>www.2ccc.com就有
 
我的~谢谢各位师兄对小弟的帮助~以后多交流
 
下面是我对这两个问题的综合完善~交流交流<br>//获取内存信息<br>procedure TForm1.Button7Click(Sender: TObject);<br>var<br> &nbsp;mems:_MEMORYSTATUS;<br> &nbsp;m,n,i,A:integer;<br>begin<br> &nbsp;Memo1.Clear ;<br> &nbsp;GlobalMemoryStatus(mems);<br> &nbsp;mems.dwLength:=sizeof(mems);<br> &nbsp;m:=MemS.dwTotalPhys div 1024;<br> &nbsp;n:=MemS.dwAvailPhys div 1024;<br> &nbsp;A:=m-n;<br> &nbsp;i:=(n * 100)div m;<br> &nbsp;Memo1.Lines.Add('可用内存百分率:'+inttostr(i)+' %');<br> &nbsp;Memo1.Lines.Add('总内存:'+inttostr(m)+'k');<br> &nbsp;Memo1.Lines.Add('可用内存:'+inttostr(n)+'k'); &nbsp;<br> &nbsp;Memo1.Lines.Add('已用内存:'+inttostr(A) +'k');<br>end;<br><br>//获取磁盘空间大小<br>procedure TForm1.Button8Click(Sender: TObject);<br>var<br> &nbsp;FreeAvaiLable: int64;<br> &nbsp;TotalSpace: int64;<br> &nbsp;TatalFree: TLargeInteger;<br> &nbsp;A,B,C:real;<br>begin<br> &nbsp;Memo1.Clear ;<br> &nbsp;if GetDiskFreeSpaceEx('C:/', FreeAvaiLable,TotalSpace, @TatalFree) then<br> &nbsp;begin<br> &nbsp; &nbsp;A:=TotalSpace/1024/1024/1024;<br> &nbsp; &nbsp;B:=TatalFree/1024/1024/1024;<br> &nbsp; &nbsp;C:=A-B;<br> &nbsp; &nbsp;Memo1.Lines.Add('C盘的总空间为:'+FormatFloat('0.00',A)+'G');<br> &nbsp; &nbsp;Memo1.Lines.Add('C盘的已用空间为:'+FormatFloat('0.00',C)+'G');<br> &nbsp; &nbsp;Memo1.Lines.Add('C盘的可用空间为:'+FormatFloat('0.00',B)+'G'); &nbsp;<br> &nbsp;end;<br>end;
 
to weiliu<br>可以给个完整的网址吗?谢谢
 
现在还有这两个问题没有完全解答,大家多多指点.<br>2、获取CPU信息<br>6、检测驱动器是否准备就绪
 
http://www.2ccc.com/article.asp?articleid=2899
 
多人接受答案了。
 
后退
顶部