Таже пока не могу определить именно CD-ROM. Но должно решаться через FileSystemObject. Там можно определить все буквы дисков на компе и есть возможность определения их типа. Но в этом месте у меня возникли сложности. Вот фрагмент из хелпа. The File System Object (FSO) model provides an object-based tool for working with folders and files. It allows you to use the familiar object.method syntax with a rich set of properties, methods, and events to process folders and files. You can also employ the traditional Visual Basic statements and commands. The FSO model gives your application the ability to create, alter, move, and delete folders, or to determine if and where particular folders exist. It also enables you to get information about folders, such as their names and the date they were created or last modified. The FSO model makes processing files much easier as well. When processing files, your primary goal is to store data in an efficient, easy-to-access format. You need to be able to create files, insert and change the data, and output (read) the data. Although you can store data in a database, doing so adds a significant amount of overhead to your application. You may not want to have such overhead, or your data access requirements may not call for the extra functionality associated with a full-featured database. In this case, storing your data in a text file or binary file is the most efficient solution. The FSO model, contained in the Scripting type library (Scrrun.dll), supports the creation and manipulation of text files through the TextStream object; however, the FSO model does not support binary files. To manipulate binary files, use the FileOpen Function with the Binary keyword. The following objects make up the FSO model: Object | Description |
---|
FileSystemObject | Allows you to create, delete, gain information about, and generally manipulate drives, folders, and files. Many of the methods associated with this object duplicate those in the other objects. | Drive | Allows you to gather information about a drive attached to the system, such as how much room is available and what its share name is. Note that a "drive" under the FSO model isn't necessarily a hard disk: it can be a CD-ROM drive, a RAM disk, and so forth. A drive also isn't required to be physically attached to the system; it can also be logically connected through a local area network (LAN). | Folder | Allows you to create, delete, or move folders, as well as query the system about their names, paths, and other information. | File | Allows you to create, delete, or move files, as well as query the system about their names, paths, and other information. | TextStream | Enables you to read and write text files. |
For information about the various properties, methods, and events in the FSO model, use the Object Browser in Visual Basic by pressing CTRL+ALT+J and looking at the Scripting type library. If the Scripting type library does not appear in the list, create a reference to it as shown in the next section. Programming in the FSO ModelProgramming in the FSO model entails three main tasks: - Creating a FileSystemObject object by using the CreateObject method, or by dimensioning a variable as a FileSystemObject object.
- Using the appropriate method on the newly created object.
- Accessing the object's properties.
The FSO model is contained in the Scripting type library, which is located in the file Scrrun.dll. If you don't already have a reference to it, you can create one. To create a reference to the Scripting type library (Scrrun.dll) - On the Project menu, click Add Reference, and then click the COM tab.
- Choose Microsoft Scripting Runtime from the Component Name list, and then click Select.
You can now use the Object Browser to view the FSO model's objects, collections, properties, methods, events, and constants.
To create a FileSystemObject object In the second example, Scripting is the name of the type library, and FileSystemObject is the name of the object of which you want to create an instance. Note The first method works only in Visual Basic, while the second method works either in Visual Basic or VBScript. FSO MethodsThe following table shows FSO methods and the tasks that they perform: Task | Command |
---|
Create a new object | CreateFolder or CreateTextFile | Delete a file or folder | DeleteFile or File.Delete; DeleteFolder or Folder.Delete | Copy an object | CopyFile or File.Copy; CopyFolder or Folder.Copy | Move an object | MoveFile or File.Move; MoveFolder or Folder.Move | Access an existing drive, folder, or file | GetDrive, GetFolder, or GetFile |
Note The FSO model does not support the creation or deletion of drives. As you can see, some functionality in the FileSystemObject object model is redundant. For example, you can copy a file using either the CopyFile method of the FileSystemObject object, or you can use the Copy method of the File object. The methods work the same way; both versions are included to give you maximum p
Ответить
|