Jump to content

how to find drive letter of usb memorystick?


Recommended Posts

How can I find the path/drive letter to a usb memory stick from labview? I would like to autosave data to the memorystick but sometimes it got a diffrent drive letter so I cant use a static path i.e asume that "S:" is the usb memorystick. I dont need to detect when its inserted, I just want to know the path/drive letter when the data should be saved to the stick.

I tried the "list directory" vi and looked at the mounted volymes, and identified the usb stick with a hiddenfile in the root dir, but that doesnt seems bulletprof. You cant use any memorystick, it have to be prepared with that hidden file.

Any other suggestions?

Link to comment

QUOTE (goran @ Nov 13 2008, 07:44 AM)

I have written a vb script that works, it just echos the drive letter, but how can I use this script in labview or port it to labview g language? Im using version 7.1 of labview

I dont have LabVIEW 7.1 to hand right now (and cant remember whether .net support was in that version) but a simple .NET call can be used to find out what drives are on a system, whether they are fixed, removable, or CD-ROM, and what their volume name and drive letters are (there are also many more properties). I've attached a picture of what the code could look like.

Link to comment

I tried to recreate Dan's vi with lw 7.1 but I cant get it to work, I get a error at the 'Call Library Function Node', the error is

LabVIEW: AN exception occured within the external code called by a Call Library Node.

Can someone please look at Dan's vi and mine and spot the error, I use this fucntion prototype

unsigned long GetDriveTypeA(CStr arg1);

in the Call Library Node, is that right? I guess not :)

Link to comment

QUOTE (goran @ Nov 14 2008, 06:59 AM)

I tried to recreate Dan's vi with lw 7.1 but I cant get it to work, I get a error at the 'Call Library Function Node', the error is

LabVIEW: AN exception occured within the external code called by a Call Library Node.

Can someone please look at Dan's vi and mine and spot the error, I use this fucntion prototype

unsigned long GetDriveTypeA(CStr arg1);

in the Call Library Node, is that right? I guess not :)

There were a couple of things:

1. When calling a Win32 function, you need to ensure that you are using the "stdcall (WINAPI)" Calling Convention - that makes the function node work

2. When casting an integer to an ENUM you need to make sure that the ENUM and the integer are the same type (ie I32/U32/U16/etc).

Here's an updated version in LV 7.1

Link to comment

QUOTE (goran @ Nov 14 2008, 05:59 AM)

I tried to recreate Dan's vi with lw 7.1 but I cant get it to work, I get a error at the 'Call Library Function Node', the error is

LabVIEW: AN exception occured within the external code called by a Call Library Node.

Can someone please look at Dan's vi and mine and spot the error, I use this fucntion prototype

unsigned long GetDriveTypeA(CStr arg1);

in the Call Library Node, is that right? I guess not :)

Try changing the enum constants to U32 representation.

Edit: Actually the calling convention should be changed from c to winapi

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.