Class: Vmopt::DVDOperation

Inherits:
Object
  • Object
show all
Defined in:
lib/vmopt/dvd_operation.rb

Instance Method Summary collapse

Instance Method Details

#close_dvd(str1 = "set cdauto door closed", str2 = "", num1 = 0, num2 = 0) ⇒ Object

参数:无功能:关闭光驱与弹出光驱对应返回值:默认



40
41
42
43
# File 'lib/vmopt/dvd_operation.rb', line 40

def close_dvd(str1="set cdauto door closed",str2="",num1=0,num2=0)
  mci = Win32API.new("winmm.dll","mciSendString",%w(p p i i),"i")
  mci.call(str1,str2,num1,num2)    
end

#disable_all_dvdObject

参数:无功能:禁用系统所有的光驱设备返回值:默认



50
51
52
# File 'lib/vmopt/dvd_operation.rb', line 50

def disable_all_dvd
  system("devcon.exe disable *DVD* >null 2>&1")
end

#disable_index_dvd(str) ⇒ Object

参数:盘符号例如D: 功能:禁用指定盘符的光驱设备返回值:默认



59
60
61
62
63
64
65
# File 'lib/vmopt/dvd_operation.rb', line 59

def disable_index_dvd(str)
  colItems = WMI.execquery ("select * from Win32_CDROMDrive where Drive='#{str}'") 
  for colItem in colItems do 
    strID = colItem.DeviceId
    system("devcon.exe disable @#{strID}  >null 2>&1")
  end      
end

#eject_dvd(str1 = "set cdauto door open", str2 = "", num1 = 0, num2 = 0) ⇒ Object

参数:无功能:弹出光驱返回值:默认



30
31
32
33
# File 'lib/vmopt/dvd_operation.rb', line 30

def eject_dvd(str1="set cdauto door open",str2="",num1=0,num2=0)
  mci = Win32API.new("winmm.dll","mciSendString",%w(p p i i),"i")
  mci.call(str1,str2,num1,num2)
end

#enable_all_dvdObject

参数:无功能:启用系统所有的光驱设备返回值:默认



72
73
74
# File 'lib/vmopt/dvd_operation.rb', line 72

def enable_all_dvd
  system("devcon.exe enable *DVD*  >null 2>&1 ")
end

#get_dvd_informationObject

参数:无功能:获取光驱的基本信息返回值:默认



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/vmopt/dvd_operation.rb', line 12

def get_dvd_information()
  data_value={}
  colItems = WMI.execquery ("select * from Win32_CDROMDrive")
  for colItem in colItems do 
    str={"介质类型"=>colItem.MediaType,
         "盘符"=> colItem.Drive,
         "描述信息"=>colItem.Description
     }
     data_value["#{colItem.Drive}"]=str
  end
  return data_value
end

#mount_all_dvdObject

参数:无功能:自动添加或者挂载所有光驱设备返回值:默认



103
104
105
# File 'lib/vmopt/dvd_operation.rb', line 103

def mount_all_dvd
  system("devcon.exe rescan  >null 2>&1")
end

#read_dvd(str) ⇒ Object

参数:盘符号例如D: 功能:打开光盘里的内容返回值:默认



112
113
114
115
# File 'lib/vmopt/dvd_operation.rb', line 112

def read_dvd(str)
  #AutoItX3.run("explorer.exe #{str}")

  system("dir  #{str}  >null 2>&1")
end

#remove_all_dvdObject

参数:无功能:删除或卸载统所有的光驱设备返回值:默认



82
83
84
# File 'lib/vmopt/dvd_operation.rb', line 82

def remove_all_dvd
  system("devcon.exe remove *DVD*  >null 2>&1")
end

#remove_index_dvd(str) ⇒ Object

参数:盘符号例如D: 功能:删除或卸载指定盘符的光驱设备返回值:默认



91
92
93
94
95
96
97
# File 'lib/vmopt/dvd_operation.rb', line 91

def remove_index_dvd(str)
  colItems = WMI.execquery ("select * from Win32_CDROMDrive where Drive='#{str}'") 
    for colItem in colItems do  
      strID = colItem.DeviceId
      system("devcon.exe remove @#{strID}  >null 2>&1")
    end     
end