deviceiocontrol

Converting a drive letter to a Partition ID / Disk ID

 ̄綄美尐妖づ 提交于 2019-12-05 19:35:16
Given a drive letter, how do I get the OSImage InstallTo Partition ID and Disk ID without using the registry? unixman83 The WMI class Win32_DiskPartition is what I need. Now to figure out how to use WMI to get this information from a drive letter. Win32_LogicalDisk is also useful, MSDN Example , and this stackoverflow answer . Update: Hmm, this doesn't work! Not in the Windows Installer anyway ( WMI is missing from Windows PE !!) so I am using the other answer QueryDosDevice (e.g. \\.\PhysicalDisk1\Partition0 ) and hacking it together. This sucks Microsoft, accept a damn path in your installer

Getting a Folder ID C#

亡梦爱人 提交于 2019-12-05 08:57:05
I am trying to track a files and folders through their lifetime (they may be moved or renamed). I have done searching and found that FileSystemWatcher might be the most popular way to track files and folders, however, this will not work for me as the application may or may not be always running. I have chosen to try to track the folders via an ID. I have found a way to track files from an ID from the answer to this stack post . I can successfully grab file IDs based on Approach B in this answer . While searching I found this stack post stating he found his solution using FSCTL_GET_OBJECT_ID .

How to disconnect a bluetooth device from C# .Net in Win7

懵懂的女人 提交于 2019-12-04 15:54:02
I would like to disconnect a bluetooth device from my c# .Net application, that runs on Win 7 x64. I Know that MS provides very little functionnality reguarding BT on .Net. I've searched 32feet.Net, and found how to connect, discover, get information, ... but nothing about disconnecting (Have I missed something ?). Then, I found on Msdn IOCTL_BTH_DISCONNECT_DEVICE . The problem is that I can't understand how to call it. It Seems that I shoud use DeviceIOControl with Platform Invoke, but I'm afraid that I haven't got enough .Net skills to build this by myself. Here is where I am at the moment :

Windows CDROM Eject

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Does anyone know a method to programmatically close the CD tray on Windows 2000 or higher? Open CD tray exists, but I can't seem to make it close especially under W2k. I am especially looking for a method to do this from a batch file, if possible, but API calls would be OK. 回答1: Here is an easy way using the Win32 API: [DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi)] protected static extern int mciSendString(string lpstrCommand,StringBuilder lpstrReturnString,int uReturnLength,IntPtr hwndCallback); public void

Getting a Folder ID C#

白昼怎懂夜的黑 提交于 2019-12-01 03:56:39
问题 I am trying to track a files and folders through their lifetime (they may be moved or renamed). I have done searching and found that FileSystemWatcher might be the most popular way to track files and folders, however, this will not work for me as the application may or may not be always running. I have chosen to try to track the folders via an ID. I have found a way to track files from an ID from the answer to this stack post. I can successfully grab file IDs based on Approach B in this

In .NET, how do I Create a Junction in NTFS, as opposed to a Symlink?

泪湿孤枕 提交于 2019-11-30 06:44:47
I'm trying to create an NTFS Junction. From the cmd line I can do this using the junction.exe tool from sysinternals . The output of a DIR cmd for a junction looks like this: Volume in drive C has no label. Volume Serial Number is C8BC-2EBD Directory of c:\users\cheeso\Documents 03/22/2009 09:45 PM <JUNCTION> My Music [\??\c:\users\cheeso\Music] 05/11/2007 05:42 PM <DIR> My Received Files 03/22/2009 09:46 PM <JUNCTION> my videos [\??\c:\users\cheeso\Videos] I read somewhere that Junctions are a subset of Symbolic Links. So I tried using CreateSymbolicLink to create a Junction. When I do this,

In .NET, how do I Create a Junction in NTFS, as opposed to a Symlink?

孤者浪人 提交于 2019-11-29 06:28:23
问题 I'm trying to create an NTFS Junction. From the cmd line I can do this using the junction.exe tool from sysinternals. The output of a DIR cmd for a junction looks like this: Volume in drive C has no label. Volume Serial Number is C8BC-2EBD Directory of c:\users\cheeso\Documents 03/22/2009 09:45 PM <JUNCTION> My Music [\??\c:\users\cheeso\Music] 05/11/2007 05:42 PM <DIR> My Received Files 03/22/2009 09:46 PM <JUNCTION> my videos [\??\c:\users\cheeso\Videos] I read somewhere that Junctions are

Pinvoke DeviceIoControl parameters

☆樱花仙子☆ 提交于 2019-11-29 03:48:39
I'm working on a C# project using DeviceIoControl . I've consulted the related Pinvoke.net page for my signature: [DllImport("Kernel32.dll", SetLastError = false, CharSet = CharSet.Auto)] public static extern bool DeviceIoControl( SafeFileHandle hDevice, EIOControlCode IoControlCode, [MarshalAs(UnmanagedType.AsAny)] [In] object InBuffer, uint nInBufferSize, [MarshalAs(UnmanagedType.AsAny)] [Out] object OutBuffer, uint nOutBufferSize, out uint pBytesReturned, [In] IntPtr Overlapped ); I'd never seen object and [MarshalAs( UnmanagedType.AsAny )] before, but the MSDN documentation sounded

Physical disk size not correct (IoCtlDiskGetDriveGeometry)

懵懂的女人 提交于 2019-11-28 09:28:09
I use the code below to get the physical disk size , but the size returned is not correct. I've checked the size with other tools. The code below reports Total disk space: 8.249.955.840 bytes and it should be Total disk space: 8.254.390.272 bytes How can I retrieve the actual/correct physical disk size? Tested on USB drives and normal hard drives. The code is long, here separate it in parts to show. The structure: [StructLayout(LayoutKind.Sequential)] internal struct DiskGeometry { public long Cylinders; public int MediaType; public int TracksPerCylinder; public int SectorsPerTrack; public int

Pinvoke DeviceIoControl parameters

扶醉桌前 提交于 2019-11-27 17:50:59
问题 I'm working on a C# project using DeviceIoControl. I've consulted the related Pinvoke.net page for my signature: [DllImport("Kernel32.dll", SetLastError = false, CharSet = CharSet.Auto)] public static extern bool DeviceIoControl( SafeFileHandle hDevice, EIOControlCode IoControlCode, [MarshalAs(UnmanagedType.AsAny)] [In] object InBuffer, uint nInBufferSize, [MarshalAs(UnmanagedType.AsAny)] [Out] object OutBuffer, uint nOutBufferSize, out uint pBytesReturned, [In] IntPtr Overlapped ); I'd never