Author |
Topic |
|
m-one
0 Posts |
Posted - 15 Aug 2007 : 01:07:45
|
Hi,
I'm trying to obtain a volume handle to CF card on TurboXb board using CreateFile API in C# but it always return invalid volume handle (-1) with error code 87.
Here is the code I'm using
[DllImport("coredll.dll", EntryPoint = "CreateFile", SetLastError = true)] private static extern IntPtr CreateFileCE( string lpFileName, uint dwDesiredAccess, uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
private void GetVolumeHandle() { string deviceName = @"Storage CardVol:"; IntPtr hVolume = CreateFileCE(deviceName, 3 /*(uint)FileAccess.ReadWrite*/, 0, IntPtr.Zero, 3 /*(uint)FileCreateDisposition.OpenExisting*/, 0, IntPtr.Zero); }
Is this the correct way or there's another way to obtain the volume handle?
|
|
ctacke
877 Posts |
Posted - 15 Aug 2007 : 01:31:28
|
No, the device name is wrong (and you're probably using the completely wrong API set to get what you're after anyway). What exactly do you plan to do with the "volume handle"? You're probably after the storage manager APIs, but again, without knowing your goal it's a bit tough to say. |
|
|
m-one
0 Posts |
Posted - 15 Aug 2007 : 02:28:04
|
Thanks for the reply,
The devicename path separator got stripped, I should have preview the post before posting it. The device name should be "\Storage Card\Vol:", I'm trying to use DeviceIOControl with IOCTL_DISK_SCAN_VOLUME to do a scandisk against the CF card like described in this article from http://msdn2.microsoft.com/en-us/library/ms891377.aspx
Thanks,
Luthfi |
|
|
beitman
63 Posts |
Posted - 05 Sep 2007 : 17:51:40
|
Error 87 is invalid parameter.
I think that the desired access (parameter 2) is out of range. I think that it should be 0xC0000000.
|
|
|
m-one
0 Posts |
Posted - 06 Sep 2007 : 02:18:33
|
Yes that was the problem, I just assume that FileAccess enum has the same value as the API constants counterpart, the FileCreateDisposition enum has the same value though. |
|
|
|
Topic |
|
|
|