WinCC.net

Home
FAQs
Downloads
Feedback

FAQs

Querying Drive Information

The System Info Channel in WinCC allows you to create tags that looks at the free space of a hard drive. However it does not seem to be able to query a removable drive. To get around this problem you can use the FileSystemObject to query the drive.

Below is a code snippet that will return the Available Space & Total Size of the C drive into two internal float tags.



/***
*** This code snippet will read the data for a drive on the machine.
*** It reads the data for two properties (.AvailableSpace & .TotalSize) and writes the results to two internal tags.

*** For a full list of properties available please look at the following web site:
*** http://www.aspalliance.com/wiseasp/aboutfilesystemobject.asp
***/

__object *fso, *drive;
fso = __object_create("Scripting.FileSystemObject");
drive = fso->GetDrive("C");

SetTagFloat("SpaceAvailable", drive->AvailableSpace());
SetTagFloat("TotalSize", drive->TotalSize());
SetTagByte("DriveType", drive->DriveType());

__object_delete(drive);
__object_delete(fso);

NB: The C script examples use the OLE Automation interface in WinCC which is an unsupported interface. If possible you should try to use the VBS script interface to access objects. The examples have been tested by myself but please be aware that you use them at your own risk.

2007 Salma Ghafoor