All pastes #205968 Raw Edit

Macca

public text v1 · immutable
#205968 ·published 2006-10-17 04:27 UTC
rendered paste body
		[DllImport("kernel32.dll", SetLastError = true, EntryPoint = "CreateFileA")]
		internal static extern IntPtr CreateFile(String filename, UInt32 desiredAccess, UInt32 shareMode, IntPtr attributes, UInt32 creationDisposition, UInt32 flagsAndAttributes, IntPtr templateFile);
		internal const long GENERIC_READ = 0x80000000L;
		internal const long FILE_SHARE_READ = 0x00000001;
		internal const long FILE_SHARE_WRITE = 0x00000002;
		internal const long OPEN_EXISTING = 3;

		private void Load()
		{
			IntPtr Handle = CreateFile(@"\\.\PhysicalDisk1", (uint)GENERIC_READ, (uint)(FILE_SHARE_READ | FILE_SHARE_WRITE), IntPtr.Zero, (uint)OPEN_EXISTING, 0, IntPtr.Zero);
			if (Handle.ToInt32() == -1)
			{
				textBox1.Text = "CreateFile() failed.";
			}
			else
			{
				textBox1.Text = "CreateFile() success.";
			}
		}