当前位置: 代码迷 >> VFP >> 请教怎么将检测出的U盘盘符和容量分别传递给text1和text
  详细解决方案

请教怎么将检测出的U盘盘符和容量分别传递给text1和text

热度:2026   发布时间:2013-02-26 00:00:00.0
请问如何将检测出的U盘盘符和容量分别传递给text1和text
C# code
VFP9.0,把下面代码放到你的 Combo1 控件的 Init 事件:This.Clearm.loWMI = Getobject("winmgmts:\\.\root\cimv2")m.loDisks = m.loWMI.ExecQuery([Select * From Win32_DiskDrive Where InterfaceType="USB"])m.loParts = m.loWMI.ExecQuery([Select * From Win32_LogicalDiskToPartition])For Each m.loDisk In m.loDisks    m.lcDevID = 'Disk #' + Transform(m.loDisk.Index)    For Each m.loPart In m.loParts        If At(m.lcDevID, m.loPart.Antecedent) > 0            This.AddItem(Strextract(m.loPart.Dependent, [DeviceID="], ["], 1)+' 容量:'+Transform(Diskspace(Strextract(m.loPart.Dependent, [DeviceID="], ["], 1),1)/1024/1024/1024)+'G')        Endif    EndforEndforRelease m.loWMI然后再加个 Timer 控件,此控件的 Interval 值为1000,意思是1秒执行一行此控件的 Timer 事件代码为:This.Enabled= .F.Thisform.Combo1.Init()This.Enabled= .T.


以上是十豆三先生给的代码。多谢他

请问如何将检测出的U盘盘符和容量分别传递给text1和text2
当点击combo1的时候可以列出下拉的U盘和容量。
当点击选择一个的时候,如何将这个盘符传递给text1,而将其容量传递给text2,。
比如有个U盘H;容量4g。当从combo1中选择这个u盘的时候,text1自动得到值H,而text2自动得到值4g。

------解决方案--------------------------------------------------------
在 Combo1 的 InteractiveChange 事件写代码:
Thisform.Text1.Value=Left(This.DisplayValue,1)
Thisform.Text2.Value=Substr(This.DisplayValue,9)
  相关解决方案