From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading System Drives in Windows with LabVIEW

Hi-

Any idea on how to query a Windows system to get the drive listing (as in My Computer) with LabVIEW? I cannot find it in the directory structure or within any of the desktop folders. Any ideas?

Thanks-

-Randy
0 Kudos
Message 1 of 11
(4,498 Views)
You can use the "List.vi" to accomplish this.

C/P description: "The vi returns two arrays of strings listing the names of all files and directories found in directory path, filtering both arrays based upon pattern and filtering the file names array based upon the specified datalog type."

It is located in the Functions Palette under
> File IO
> Advanced File Functions

Actually, most of the vi's that you'll need are located here. You can combine this with String functions to create anything you want.

Have fun,

JLV
Message 2 of 11
(4,498 Views)
Thanks for the response. I know the VI, and use it often. The problem is that it requires an input path, and THAT is what I do not know. I want to read the list of drives (A:, C:, etc.) and have to be "above" it in the directory structure to be able to list it. Do you know how to do this?

Thanks-

-Randy
0 Kudos
Message 3 of 11
(4,498 Views)
I tried the List VI again, but this time I put a valid, blank path as an input, and by golly, the drives appear! I've never seen it documented, but there it is! Thanks!!
Message 4 of 11
(4,498 Views)

Wiring an empty path should give you the root drives(e.g. A=Floppy, C=Hard Disk, D=CDROM, etc.

(see attached image. Sorry, this is on a Laptop with only a C drive, but I've used it many times on better endowed machines).

 

Message 5 of 11
(4,498 Views)
Thanks! That's what I was looking for!

-Randy
0 Kudos
Message 6 of 11
(4,498 Views)

Hi,

 

Is there any way to read drive names.

Other than drive letters (C,D,E...).

 

 

Thanksa & Regards,

Hari.

0 Kudos
Message 7 of 11
(4,011 Views)

Hello Hari,

 

You can use .NET calls to get this information.

 

On .NET versions 4.5 and 4.6 in the System.IO there is a DriveInfo class where you can get all information on the hard drives.

 

https://msdn.microsoft.com/en-us/library/system.io.driveinfo(v=vs.110).aspx

 

I have tried to run it on my laptop but on .NET 4.0 you can't create a constructor for the System.IO

 

 

Guilherme Correa
0 Kudos
Message 8 of 11
(4,006 Views)

Instead you could run the Windows API function

BOOL WINAPI GetVolumeInformationA(
  _In_opt_  LPCSTR lpRootPathName,
  _Out_opt_ LPSTR  lpVolumeNameBuffer,
  _In_      DWORD   nVolumeNameSize,
  _Out_opt_ LPDWORD lpVolumeSerialNumber,
  _Out_opt_ LPDWORD lpMaximumComponentLength,
  _Out_opt_ LPDWORD lpFileSystemFlags,
  _Out_opt_ LPSTR  lpFileSystemNameBuffer,
  _In_      DWORD   nFileSystemNameSize
);

Not as trivial and simple to implement as calling a .Net node but would work even in Windows NT 4.0 if that was still sold Smiley Happy and avoids the .Net version hassles.

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 11
(3,998 Views)

@altenbach wrote:
Wiring an empty path should give you the root drives(e.g. A=Floppy, C=Hard Disk, D=CDROM, etc.

(see attached image. Sorry, this is on a Laptop with only a C drive, but I've used it many times on better endowed machines).

I can't find that vi!  (LV 2014)

 

Oops, replying to a post that was made a decade ago.  Smiley Embarassed

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 11
(3,955 Views)