Morning all,
How would I go about getting the serial number of the storage/sd card on my mobile device? I am using C#.Net 2.0 on the Compact Framework V2.0.
Thanks.
Morning all,
How would I go about getting the serial number of the storage/sd card on my mobile device? I am using C#.Net 2.0 on the Compact Framework V2.0.
Thanks.
The Smart Device Framework provides a mechanism to get SD Card serial numbers and manufacturer IDs.
You need to use some unmanaged APIs. Specifically, DeviceIoControl using a 'control code' of IOCT_DISK_GET_STORAGEID. This will, in turn, return a STORAGE_IDENTIFICATION structure.
Here's where it gets a bit tricky, as STORAGE_IDENTIFICATION uses a property (dwSerialNumOffset) to specify the (memory) offset from the beginning of the structure, which would be difficult to translate into interop calls.
Edit: Found a VB.NET implementation on the MSDN forums
I'm not on a machine that I can get the syntax for you but I believe you can use the System.IO namespace to get IO based attributes.
First get a DirectoryInfo to the storage card. (I'm not 100% on the code here, you may need to test, I'll update it if I can get to my machine)
Then check all the properties on the DirectoryInfo that code returns. Thanks to the joys of debugging you should be able to see if the serial number is one of the available properties.
If not, you may need to look to something a bit more unmanaged.
Hope this helps.