I have a function that I'm trying to get working. My intention is to be able to get a file handle (IntPtr) object so that I can call "Win32.DeviceIoControl" against it. It works just fine in Windows 7, however when I test on Windows 8, I'm getting a -1 returned from object variable.
Perhaps there is a different way to do this in windows 8? or a better way to do it overall.
Here is the code:
public bool OpenHandle()
{
string filename = "\\\\.\\D:";
hFile = Win32.CreateFile(filename, Win32.GENERIC_READ | Win32.GENERIC_WRITE,
Win32.FILE_SHARE_READ | Win32.FILE_SHARE_WRITE, IntPtr.Zero, Win32.OPEN_EXISTING, 0, IntPtr.Zero);
if (hFile.ToInt32() == Win32.INVALID_HANDLE)
{
return false;
}
return true;
}
This code was taken from https://stackoverflow.com/a/9579881/1607306 , I'm just trying to utilize it. Again, working in Win7, not Win8.
Thanks!