展开全部
IONOUTPARAMS(); uint bytRv = 0; if (0 != DeviceIoControl(device, DFP_GET_VERSION, 0, 0, ref verPara, Marshal.SizeOf(verPara), ref bytRv, 0)) { if (verPara.bIDEDeviceMap > 0) { byte bIDCmd = (byte)(((verPara.bIDEDeviceMap >> drive & 0x10) != 0) ? IDE_ATAPI_IDENTIFY : IDE_ATA_IDENTIFY); SENDCMDINPARAMS scip = new SENDCMDINPARAMS(); SENDCMDOUTPARAMS scop = new SENDCMDOUTPARAMS(); scip.cBufferSize = IDENTIFY_BUFFER_SIZE; scip.irDriveRegs.bFeaturesReg = 0; scip.irDriveRegs.bSectorCountReg = 1; scip.irDriveRegs.bCylLowReg = 0; scip.irDriveRegs.bCylHighReg = 0; scip.irDriveRegs.bDriveHeadReg = (byte)(0xA0 | ((drive & 1) << 4)); scip.irDriveRegs.bCommandReg = bIDCmd; scip.bDriveNumber = drive; if (0 != DeviceIoControl(device, DFP_RECEIVE_DRIVE_DATA, ref scip, Marshal.SizeOf(scip), ref scop, Marshal.SizeOf(scop), ref bytRv, 0)) { StringBuilder s = new StringBuilder(); for (int i = 20; i < 40; i += 2) { s.Append((char)(scop.bBuffer[i+1])); s.Append((char)scop.bBuffer[i]); } CloseHandle(device); return s.ToString().Trim(); } } } CloseHandle(device); return ""; } } 文章出处: http://www.diybl.com/course/4_webprogram/asp.net/asp_netshl/200727/12910_2.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private string[] GetMoc() { string[] str = new string[1]; ManagementClass mcHD = new ManagementClass("win32_logicaldisk"); ManagementObjectCollection mocHD = mcHD.GetInstances(); foreach(ManagementObject m in mocHD) { if(m["DeviceID"].ToString() == "C:") { str[0] = m["VolumeSerialNumber"].ToString(); break; } } return str; } 看看这个!
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询