08-30-2013 04:39 AM
Hello all
I couldn't find the answer to my question, so I have started a new thread.
Problem: I would like for Labview (or TestStand directly) to programatically detect if an SD (secure digital) card has the "write protection" slider switch active.
Is this possible somehow?
PS: I was also not able to find this information anywhere in Windows 7 as well. I'm using LV 2011 SP1.
PPS: At the moment I try to create a file on the SD card, and detect the write error, which tells me if the card is protected or not. But I would like a more elegant solution.
Solved! Go to Solution.
08-30-2013 06:29 AM
You could try to use the GetVolumeInformation function provided by Win32API.
It should return you a flag stating the device is read only....
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364993%28v=vs.85%29.aspx
http://support.microsoft.com/kb/139547
Regards,
Marco
08-30-2013 06:30 AM - edited 08-30-2013 06:32 AM
Unless you want to dive deeply into Windows device drivers itself and intercept some messages on that API level I'm afaid your way of detecting write protection is the only feasable one.
The link by Marco might give you a feasable solution, the problem is that those flags are not always correct for all possible mediums including network shares.
08-30-2013 06:35 AM - edited 08-30-2013 06:43 AM
This is a hardware 'problem'.
The write protect function is set by the reader itself by physically engaging a switch depending on the write protect slider position. You can usually override this behaviour from the registry, but that's besides the point.
Your approach is the only one that I've ever seen work without gaining access to that switch via IO. You can't use Get Permissions because Windows sees the permissions the same regardless of the slider position.
As for elegance, it sounds pretty elegant to me already 🙂
Edit - you learn something new every day.
Write protect engaged: 000010000000000000000110
Write protect disengaged: 000000000000000000000110
I will hang my head in shame and rewrite some VIs now!
08-30-2013 06:35 AM
Wow, it's already there for Labview: http://zone.ni.com/devzone/cda/epd/p/id/2048
All you have to do (hopefully) is to parse that "flags" value!!
Marco
09-16-2013 01:33 AM
Hi guys
Thanks for the suggestions.
I got what I needed, both a simple and a more advanced solution 🙂
-Kim
09-16-2013 01:48 AM
Hi Kim.
If you want you can mark the issue as solved and give kudos ;=)
Marco
03-29-2017 12:14 AM
i had similar issue with my sd card i have followed steps in this post and it solved my issue of sd card write protected. i hope you will also get your solution on write protected issue.