分享
 
 
 

DeviceIoControl

王朝百科·作者佚名  2010-03-06
窄屏简体版  字體: |||超大  

DeviceIoControl

VB声明

Declare Function DeviceIoControl Lib "kernel32" Alias "DeviceIoControl" (ByVal hDevice As Long, ByVal dwIoControlCode As Long, lpInBuffer As Any, ByVal nInBufferSize As Long, lpOutBuffer As Any, ByVal nOutBufferSize As Long, lpBytesReturned As Long, lpOverlapped As OVERLAPPED) As Long

说明

对设备执行指定的操作

返回值

Long,非零表示成功,零表示失败。会设置GetLastError

参数表

参数 类型及说明

hDevice Long,设备句柄

dwIoControlCode Long,带有 FSCTL_ 前缀的常数。参考设备控制选项的部分列表

lpInBuffer Any,具体取决于dwIoControlCode参数。参考设备控制选项的部分列表

nInBufferSize Long,输入缓冲区的长度

lpOutBuffer Any,具体取决于dwIoControlCode参数。参考设备控制选项的部分列表

nOutBufferSize Long,输出缓冲区的长度

lpBytesReturned Long,实际装载到输出缓冲区的字节数量

lpOverlapped OVERLAPPED,这个结构用于重叠操作。针对同步操作,请用ByVal As Long传递零值

注解

可用于windows 95 和 windows nt,但并非所有的操作都得到了两种操作系统的同时支持

vc下的DeviceIoControl 函数定义

[font]DeviceIoControl Function

Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.

<h3 style="font-size: 110%; font-weight: 700; ">Syntax</h3>

<pre class="libCScode" id="ctl00_rs1_mainContentContainer_ctl01" space="preserve" style="white-space: pre-wrap; background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(221, 221, 221); border-top-color: rgb(200, 205, 222); border-top-style: solid; border-top-width: 1px; padding-left: 5px; padding-right: 5px; padding-top: 5px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; display: block; font-family: Verdana, Arial, Helvetica, sans-serif; background-position: initial initial; ">BOOL WINAPI DeviceIoControl( __in HANDLEhDevice, __in DWORDdwIoControlCode, __in_opt LPVOIDlpInBuffer, __in DWORDnInBufferSize, __out_opt LPVOIDlpOutBuffer, __in DWORDnOutBufferSize, __out_opt LPDWORDlpBytesReturned, __inout_opt LPOVERLAPPEDlpOverlapped);</pre>

<h3 style="font-size: 110%; font-weight: 700; ">Parameters</h3><dl style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 1px; "><dt style="font-style: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">hDevice [in]</dt><dd>A handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device handle, use the CreateFilefunction. For more information, see Remarks.

</dd><dt style="font-style: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">dwIoControlCode [in]</dt><dd>The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.

For a list of the control codes, see Remarks. The documentation for each control code provides usage details for the lpInBuffer,nInBufferSize, lpOutBuffer, and nOutBufferSize parameters.

</dd><dt style="font-style: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">lpInBuffer [in, optional]</dt><dd>A pointer to the input buffer that contains the data required to perform the operation. The format of this data depends on the value of the dwIoControlCode parameter.

This parameter can be NULL if dwIoControlCode specifies an operation that does not require input data.

</dd><dt style="font-style: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">nInBufferSize [in]</dt><dd>The size of the input buffer, in bytes.

</dd><dt style="font-style: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">lpOutBuffer [out, optional]</dt><dd>A pointer to the output buffer that is to receive the data returned by the operation. The format of this data depends on the value of the dwIoControlCode parameter.

This parameter can be NULL if dwIoControlCode specifies an operation that does not return data.

</dd><dt style="font-style: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">nOutBufferSize [in]</dt><dd>The size of the output buffer, in bytes.

</dd><dt style="font-style: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">lpBytesReturned [out, optional]</dt><dd>A pointer to a variable that receives the size of the data stored in the output buffer, in bytes.

If the output buffer is too small to receive any data, the call fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and lpBytesReturned is zero.

If the output buffer is too small to hold all of the data but can hold some entries, some drivers will return as much data as fits. In this case, the call fails, GetLastError returns ERROR_MORE_DATA, and lpBytesReturned indicates the amount of data received. Your application should callDeviceIoControl again with the same operation, specifying a new starting point.

If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation returns no output data and lpOutBuffer is NULL, DeviceIoControl makes use of lpBytesReturned. After such an operation, the value of lpBytesReturned is meaningless.

If lpOverlapped is not NULL, lpBytesReturned can be NULL. If this parameter is not NULL and the operation returns data,lpBytesReturned is meaningless until the overlapped operation has completed. To retrieve the number of bytes returned, callGetOverlappedResult. If hDevice is associated with an I/O completion port, you can retrieve the number of bytes returned by calling GetQueuedCompletionStatus.

</dd><dt style="font-style: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">lpOverlapped [in, out, optional]</dt><dd>A pointer to an OVERLAPPED structure.

If hDevice was opened without specifying FILE_FLAG_OVERLAPPED, lpOverlapped is ignored.

If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation. In this case, lpOverlapped must point to a validOVERLAPPED structure that contains a handle to an event object. Otherwise, the function fails in unpredictable ways.

For overlapped operations, DeviceIoControl returns immediately, and the event object is signaled when the operation has been completed. Otherwise, the function does not return until the operation has been completed or an error occurs.

</dd></dl><h3 style="font-size: 110%; font-weight: 700; ">Return Value</h3>If the operation completes successfully, the return value is nonzero.

If the operation fails or is pending, the return value is zero. To get extended error information, call GetLastError.

<h3 style="font-size: 110%; font-weight: 700; ">Remarks</h3>To retrieve a handle to the device, you must call the CreateFilefunction with either the name of a device or the name of the driver associated with a device. To specify a device name, use the following format:

\.DeviceName

DeviceIoControl can accept a handle to a specific device. For example, to open a handle to the logical drive A: with CreateFile, specify \.a:. Alternatively, you can use the names \.PhysicalDrive0, \.PhysicalDrive1, and so on, to open handles to the physical drives on a system.

You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device driver. However, when you open a communications resource, such as a serial port, you must specify exclusive access. Use the otherCreateFile parameters as follows when opening a device handle:

<ul style="line-height: 140%; list-style-position: outside; list-style-type: disc; margin-bottom: 15px; "><li style="margin-bottom: 3px; margin-left: 0px; list-style-image: url(http://i3.msdn.microsoft.com/Platform/MasterPages/Library/b.gif); ">The fdwCreate parameter must specify OPEN_EXISTING.</li><li style="margin-bottom: 3px; margin-left: 0px; list-style-image: url(http://i3.msdn.microsoft.com/Platform/MasterPages/Library/b.gif); ">The hTemplateFile parameter must be NULL.</li><li style="margin-bottom: 3px; margin-left: 0px; list-style-image: url(http://i3.msdn.microsoft.com/Platform/MasterPages/Library/b.gif); ">The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations.</li></ul>

<ul style="line-height: 140%; list-style-position: outside; list-style-type: disc; margin-bottom: 15px; "><li style="margin-bottom: 3px; margin-left: 0px; list-style-image: url(http://i3.msdn.microsoft.com/Platform/MasterPages/Library/b.gif); " id="bks_2c3nfugx">

</li></ul>

[/font]

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有