All Forums
 Microsoft Windows CE
 .NET Application Development
 Obtain volume handle with CreateFile problem
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

m-one

0 Posts

Posted - 15 Aug 2007 :  01:07:45  Show Profile
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  Show Profile  Email Poster
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.
Go to Top of Page

m-one

0 Posts

Posted - 15 Aug 2007 :  02:28:04  Show Profile
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
Go to Top of Page

beitman

63 Posts

Posted - 05 Sep 2007 :  17:51:40  Show Profile  Email Poster
Error 87 is invalid parameter.

I think that the desired access (parameter 2) is out of range. I think that it should be 0xC0000000.

Go to Top of Page

m-one

0 Posts

Posted - 06 Sep 2007 :  02:18:33  Show Profile
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.
Go to Top of Page
  Topic  
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Jump To:
Eurotech Support Forums © Eurotech Inc. Go To Top Of Page
This page was generated in 0.03 seconds. Snitz Forums 2000