插入U盘怎样获取U盘盘符? ( 积分: 100 )

  • 主题发起人 主题发起人 tbp99
  • 开始时间 开始时间
T

tbp99

Unregistered / Unconfirmed
GUEST, unregistred user!
插入U盘怎样获取U盘盘符?
 
插入U盘怎样获取U盘盘符?
 
什么意思??<br>你插入u盘后,u盘不能显示吗???
 
procedure TMainForm.bbtnBackupClick(Sender: TObject);<br>var<br> &nbsp;sOldFile,sNewFile,c,s: String;<br> &nbsp;i,dtype:integer;<br> &nbsp;b:Boolean;<br>begin<br> &nbsp;b:=false;<br> &nbsp;for i:=67 to 90 do<br> &nbsp;begin<br> &nbsp; &nbsp;c:=chr(i)+':/';<br> &nbsp; &nbsp;dtype:=GetDriveType(pchar(c));<br> &nbsp; &nbsp;if dtype=2<br> &nbsp; &nbsp;then<br> &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;b:=true;<br> &nbsp; &nbsp; &nbsp; &nbsp;s:=c;<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp;end;<br> &nbsp;if b then<br> &nbsp;begin<br>// &nbsp;sOldFile:='z:/wfbj.mdb';<br> &nbsp;sOldFile:=extractfiledir(paramstr(0))+'/wfbj.mdb';<br> &nbsp;sNewFile:=s+'wfbj.mdb';<br> &nbsp;if FileExists(sOldFile) then<br> &nbsp;begin<br> &nbsp; &nbsp;if CopyFile(Pchar(sOldFile),Pchar(sNewFile),FALSE) then<br> &nbsp; &nbsp;Application.MessageBox('备份成功!','提示',0)<br> &nbsp; &nbsp;else Application.MessageBox('备份没有成功!!!','提示',0);<br> &nbsp;end;<br> &nbsp;end<br> &nbsp;else ShowMessage('电子备份盘未发现,请插入电子备份盘!');<br>end;
 
procedure Getdiskinf();<br>var<br>Name: CHAR;<br>Sector, Byte, Cluster, Free: Dword;<br>begin<br> &nbsp;for Name := 'C' to 'Z' do //循环检测C~Z<br> &nbsp;begin<br> &nbsp; &nbsp;drvname := Name + ':';<br> &nbsp; &nbsp;CDtype := GetDriveType(PCHAR(@drvname[1])); //获得磁盘类型<br> &nbsp; &nbsp;case cdtype of<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DRIVE_REMOVABLE://移动驱动器<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GetDiskFreeSpace(PChar(drvname), LPDWORD(@sector)^, LPDWORD(@byte)^, LPDWORD(@free)^, LPDWORD(@cluster)^); //获得返回参数<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;totalspace := cluster * byte * sector div 1024 div 1024; //计算总容量<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;freespace := free * byte * sector div 1024 div 1024; //计算可用空间<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp;DRIVE_RAMDISK://RAMDISK<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GetDiskFreeSpace(PChar(drvname), LPDWORD(@sector)^, LPDWORD(@byte)^, LPDWORD(@free)^, LPDWORD(@cluster)^); //获得返回参数<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;totalspace := cluster * byte * sector div 1024 div 1024; //计算总容量<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;freespace := free * byte * sector div 1024 div 1024; //计算可用空间<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br>end;
 
后退
顶部