글 작성자: 써니루루

이하 내용은 구글의 루비 그룹에서 발췌한 내용입니다. ^ ^
CD-ROM을 여는 흥미로운 내용이 있어서 가져와봤네용~
Windows App.를 개발하실 일 있을때 사용하시면 될 것 같습니다.


On May 5, 8:15 pm, "Eder Quiñones" <eder...@gmail.com> wrote: > Hi, anyone knows what is the problem with this function, i believe i did > everything right, but it just does not open the cd-rom, maybe the > problem is in the part "InvokeVerb". Any help would be highly > appreciated. > > def ejectDrives > > @wbem = WIN32OLE.new('WbemScripting.SWbemLocator') > @a = @wbem.ConnectServer > @b = @a.InstancesOf('Win32_LogicalDisk') > cdroms = Array.new > > @b.each do | object | > if object.Description =~ /cd/i > cdroms << object.Name > end > end > > @shell = WIN32OLE.new('Shell.Application') > > cdroms.each do | name | > > @ej1 = @shell.NameSpace(name) > @ej2 = @ej1.Self > @ej3 = @ej2.InvokeVerb("Expu&lsar") > > end > > end > > This is another version using "WMPlayer.OCX" that actually work. > > def ejectDrivesWMP > > @wmp = WIN32OLE.new('WMPlayer.OCX') > > @cdromCol = @wmp.cdromCollection > @cdromCount = @cdromCol.Count > > i = 1 > while i <= @cdromCount > @cdromCol.Item(i - 1).Eject > i += 1 > end > > end > > -- > Posted viahttp://www.ruby-forum.com/. You might try a variation of the following (where D is the CDROM drive)... WIN32OLE.new("Shell.Application").NameSpace(17).ParseName("D:\ \").InvokeVerb("E&ject") ...or perhaps... WIN32OLE.new("Shell.Application").NameSpace(17).ParseName("D:\ \").InvokeVerb("Expu&lsar") David Mullet http://rubyonwindows.blogspot.com