vb..help|Programmering / Grafisk formgivning|Forum|Nordichardware

Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
The forums are currently locked and only available for read only access
sp_Feed sp_TopicIcon
vb..help
x1zt
Kommer du hit ofta?
Medlem
Forum Posts: 328
Member Since:
July 7, 2002
sp_UserOfflineSmall Offline
1
July 25, 2002 - 2:41 pm
sp_Permalink sp_Print

kan nån berätta hur man gör så följande kod BARA skriver ut cd-romer? nu skirver den alla enheter ju =(

on error resume Next

Const ForReading = 1, ForWriting = 2, ForAppending = 8

Dim oFileSys, oFileWrite, Drive

Set oFileSys = CreateObject("Scripting.FileSystemObject")
Count = -1

For each drv in oFileSys.Drives
Set Drive = oFileSys.GetDrive(drv.Driveletter)
Set oFileWrite = oFileSys.CreateTextFile("CD_" & Drive.DriveLetter & ".vbs", True)

oFileWrite.WriteLine("'Extended Drive Attributes Functions VBScript")
oFileWrite.WriteLine("'this is a remake by x1zt =)")
oFileWrite.WriteLine
oFileWrite.WriteLine("on error resume Next")
oFileWrite.WriteLine
oFileWrite.WriteLine("Dim oFileSys, Drive, sDriveType")
oFileWrite.WriteLine
oFileWrite.WriteLine("Set oFileSys = CreateObject(""Scripting.FileSystemObject"")")
oFileWrite.WriteLine("Set Drive = oFileSys.GetDrive(" & Chr(34) & Drive.DriveLetter & Chr(34) & Chr(41))
If Drive.DriveType = 2 Then
Count = Count + 1
oFileWrite.WriteLine("Set DiskInfoSet = GetObject(" & Chr(34)& "winmgmts:{impersonationLevel=impersonate}!//localhost" & Chr(34)_
& ").ExecQuery(" & Chr(34) & "select Model, SCSIBus, SCSILogicalUnit, SCSIPort, SCSITargetId from Win32_DiskDrive where Index = " & Count & Chr(34) & Chr(41))
oFileWrite.WriteLine
End If
oFileWrite.WriteLine
oFileWrite.WriteLine
oFileWrite.WriteLine
oFileWrite.WriteLine("'----------------------------------------------")
oFileWrite.WriteLine("'Displays individual drive volume name")
oFileWrite.WriteLine("Function VolumeName()")
oFileWrite.WriteLine
oFileWrite.WriteLine("If Drive.IsReady = True Then")
oFileWrite.WriteLine(" VolumeName = Drive.VolumeName")
oFileWrite.WriteLine("Else")
oFileWrite.WriteLine("VolumeName = ""NO CD""")
oFileWrite.WriteLine("End If")
oFileWrite.WriteLine
oFileWrite.WriteLine("End Function")
next

johnq
Siktar mot toppen
Medlem
Forum Posts: 53
Member Since:
December 6, 2001
sp_UserOfflineSmall Offline
192513
August 14, 2002 - 3:32 pm
sp_Permalink sp_Print

Du måste testa om Drive.DriveType = 4, om det är sant så är det en CD-ROM.
Kolla in exemplet i dokumentationen till VB. :bok:

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1030
Currently Online:
Guest(s) 27
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Andreas Galistel: 16287
Jonas Klar: 15897
ilg@dd: 10810
Nyhet: 10607
Mind: 10550
Ctrl: 10355
Gueno: 9881
Guest: 9344
Snorch: 8881
Callister: 8468
Newest Members:
PetrbonFU PetrbonFU
Karine Bembry
Dolores Mcdaniels
Anibal McLeish
Francisca Alt
Alfie Everhart
Lester Huitt
Orlando Jorgensen
Mikki Lundgren
Dakota Kozlowski
Forum Stats:
Groups: 11
Forums: 59
Topics: 146630
Posts: 1300967

 

Member Stats:
Guest Posters: 2
Members: 79425
Moderators: 0
Admins: 11
Administrators: nordicadmin, Henrik Berntsson, Anton Karmehed, Carl Holmberg, Joel Oscarsson, Mikael Linnér, Mikael Schwartz, Andreas Paulsson, Nickebjrk, Mattias Pettersson, EmxL