goran Posted November 14, 2008 Report Share Posted November 14, 2008 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? Quote Link to comment
Anders Björk Posted November 14, 2008 Report Share Posted November 14, 2008 Look at this http://www.activexperts.com/activmonitor/w...ts/disk/drives/ I think have to VB-script or the COM object directly. Quote Link to comment
goran Posted November 14, 2008 Author Report Share Posted November 14, 2008 QUOTE (Anders Björk @ Nov 13 2008, 11:03 AM) Look at thishttp://www.activexperts.com/activmonitor/w...ts/disk/drives/ I think have to VB-script or the COM object directly. 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 Quote Link to comment
Shaun Hayward Posted November 14, 2008 Report Share Posted November 14, 2008 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. Quote Link to comment
Dan DeFriese Posted November 14, 2008 Report Share Posted November 14, 2008 QUOTE (Shaun Hayward @ Nov 13 2008, 08:10 AM) (and cant remember whether .net support was in that version) Doesn't look like it... If your interested, you can also use the GetDriveTypeA() and GetVolumeInformation() available in Kernal32.dll. I've aready written a library node VI for GetDriveTypeA(), but I can't save it to 7.1 right now. If you need the volume name you'd need to add GetVolumeInformation() yourself. I'll repost it in 7.1 later, if no one else does it. This is LV 8.5 http://lavag.org/old_files/post-3463-1226599917.vi'>Download File:post-3463-1226599917.vi Quote Link to comment
LAVA 1.0 Content Posted November 14, 2008 Report Share Posted November 14, 2008 Dan, here is some little optimization of your code limiting the runs of the for loops. Ton PS I advice you to use the Code Capture Tool for code captures. Quote Link to comment
goran Posted November 15, 2008 Author Report Share Posted November 15, 2008 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 Quote Link to comment
Shaun Hayward Posted November 15, 2008 Report Share Posted November 15, 2008 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 isLabVIEW: 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 Quote Link to comment
Dan DeFriese Posted November 15, 2008 Report Share Posted November 15, 2008 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 isLabVIEW: 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 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.