LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read a USB Port to detect a USB Key ?

Solved!
Go to solution

Hello !

I am french and I develop a program on LabWindows/CVI 2013. 

 

I have to launch a file (aaaa.exe) when my program start. But this file (aaaa.exe) is located in a USB Key. So I have to read the USB Ports to detect the key, and after, find if the file (aaaa.exe) exists in the key. If the file (aaaa.exe) exists, I launch it. 

 

But I don't know which functions I can use to do this... ?

 

Thanks

Best regards

0 Kudos
Message 1 of 3
(3,091 Views)

If you are running on a Windows system, your computer should assign a drive letter to the USB key when it is inserted.  So if you know what drive letter will be assigned, you can call FileExists to check for the file and LaunchExecutableEx to run it.  Typically your hard drive is C and your CD/DVD drive is D, so your USB drive is likely to be E (possibly F or G if your computer has multiple CD/DVD drives or if another USB device was inserted first).  So at most you should have to check a few drive letters.

 

If you're running on a Linux system, you need to call a system function to mount the USB drive before you can access it.  This article describes how:

https://linuxconfig.org/howto-mount-usb-drive-in-linux

0 Kudos
Message 2 of 3
(3,040 Views)
Solution
Accepted by topic author Hubert_69

Thanks richferrara !

 

I've just find the solution !

In my case, I don't know the letter of my USB drive.

So I used the function "GetLogicalDriveStrings()" to catch all the Drive letter of my computer and after that I used "FileExists()" to detect my file ! 

Message 3 of 3
(3,035 Views)