网站首页  词典首页

请输入您要查询的函数:

 

术语 deviceiocontrol
释义 DeviceIoControl
语法:
C++
BOOL WINAPI DeviceIoControl(
__in HANDLE hDevice,
__in DWORD dwIoControlCode,
__in_opt LPVOID lpInBuffer,
__in DWORD nInBufferSize,
__out_opt LPVOID lpOutBuffer,
__in DWORD nOutBufferSize,
__out_opt LPDWORD lpBytesReturned,
__inout_opt LPOVERLAPPED lpOverlapped
);
DeviceIoControl函数
发送一个控制代码直接到指定的设备驱动程序,导致相应的设备来执行相应的操作。
参数
hDevice [in]
句柄到设备上的操作要执行。该设备是一个典型的体积,目录,文件或流。要检索设备处理,使用CreateFile函数。有关更多信息,请参见备注。
dwIoControlCode [in]
为操作控制代码。此值确定了具体的操作和执行的设备上执行的类型。
备注有关的控制代码清单,请参阅。每个控件的代码文档提供了详细的使用为lpInBuffer,nInBufferSize,lpOutBuffer,和nOutBufferSize参数。
lpInBuffer [中,可选]
A到输入缓冲区,其中包含需要执行的操作的数据指针。这些数据的格式取决于该dwIoControlCode参数的值。
此参数可以为NULL,如果dwIoControlCode指定的操作,不需要输入数据。
nInBufferSize [in]
在输入缓冲区的大小,以字节为单位。
lpOutBuffer [指出,可选]
甲到输出缓冲区的接收操作返回的数据的指针。这些数据的格式取决于该dwIoControlCode参数的值。
此参数可以为NULL,如果dwIoControlCode指定一个操作,不返回数据。
nOutBufferSize [in]
输出缓冲区的大小,以字节为单位。
lpBytesReturned [指出,可选]
一个变量,它接收数据的大小指针存储在输出缓冲区,以字节为单位。
如果输出缓冲区太小而无法接收任何数据,调用失败,GetLastError返回ERROR_INSUFFICIENT_BUFFER,并lpBytesReturned是零。
如果输出缓冲区太小,不能容纳所有的数据,但可以举办一些作品,一些司机只要符合返回的数据量。在这种情况下,调用失败,GetLastError返回ERROR_MORE_DATA,并lpBytesReturned表示收到的数据量。您的应用程序应调用的DeviceIoControl再次以同样的操作,指定一个新的起点。
如果lpOverlapped为NULL,lpBytesReturned不能是NULL。即使一个操作返回任何输出数据和lpOutBuffer为NULL,使的DeviceIoControl的lpBytesReturned使用。经过这样的运作模式,lpBytesReturned的价值是没有意义的。
如果lpOverlapped不为NULL,lpBytesReturned可以为NULL。如果这个参数不为NULL,操作返回数据,lpBytesReturned是毫无意义的重叠,直到操作完成。要检索的字节数返回,呼叫GetOverlappedResult。如果hDevice是与本人联系/ O完成端口,您可以检索通过调用GetQueuedCompletionStatus返回的字节数。
lpOverlapped [中,指出,可选]
一个OVERLAPPED结构的指针。
如果hDevice是没有指定FILE_FLAG_OVERLAPPED打开,lpOverlapped被忽略。
如果hDevice是与FILE_FLAG_OVERLAPPED标志打开,操作执行作为重叠(异步)操作。在这种情况下,lpOverlapped必须指向一个有效的OVERLAPPED结构,其中包含一个处理一个事件对象。否则,函数失败不可预知的方式。
对于重叠操作,立即返回的DeviceIoControl,而事件对象发出信号时,操作已完成。否则,该函数不返回,直到操作已完成或发生错误。
返回值
如果操作成功完成,则返回值为非零。
If the operation fails or is pending, the return value is zero.为了获得更多错误信息,调用GetLastError。
备注
来检索设备句柄,必须调用,或者是一个设备或与设备相关的驱动程序的名称CreateFile函数。要指定一个设备名称,使用下列格式:
\\ \\。\\设备名称
DeviceIoControl can accept a handle to a specific device.例如,要打开一个句柄逻辑驱动器A:以CreateFile,指定\\ \\。\\ 1:。或者,您可以使用的名称\\ \\。\\ PhysicalDrive0,\\ \\。\\ PhysicalDrive1等,以打开句柄的物理驱动器上的系统。
You should specify the FILE_SHARE_READ and FILE_SHARE_WRITE access flags when calling CreateFile to open a handle to a device driver.但是,当您打开如串行端口通信资源,您必须指定的独家访问。使用其他CreateFile参数如下当打开一个设备句柄:
该fdwCreate参数必须指定OPEN_EXISTING。
该hTemplateFile参数必须是NULL。
该fdwAttrsAndFlags参数可以指定FILE_FLAG_OVERLAPPED来表明,返回的句柄可以重叠(异步使用)I / O操作。
对于支持的控制代码清单,请参阅下列主题:
通讯控制代码
设备管理控制代码
目录管理控制代码
磁盘管理控制代码
文件管理控制代码
电源管理控制代码
卷管理控制代码
实例
举一个例子,它使用的DeviceIoControl,看到的DeviceIoControl调用
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
CreateEvent
CreateFile
设备输入和输出控制(IOCTL)
GetOverlappedResult
GetQueuedCompletionStatus
的OVERLAPPED
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月30日
==英文原文==DeviceIoControl Function
Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
Syntax
C++
BOOL WINAPI DeviceIoControl(
__in HANDLE hDevice,
__in DWORD dwIoControlCode,
__in_opt LPVOID lpInBuffer,
__in DWORD nInBufferSize,
__out_opt LPVOID lpOutBuffer,
__in DWORD nOutBufferSize,
__out_opt LPDWORD lpBytesReturned,
__inout_opt LPOVERLAPPED lpOverlapped
);
Parameters
hDevice [in]
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 CreateFile function. For more information, see Remarks.
dwIoControlCode [in]
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.
lpInBuffer [in, optional]
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.
nInBufferSize [in]
The size of the input buffer, in bytes.
lpOutBuffer [out, optional]
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.
nOutBufferSize [in]
The size of the output buffer, in bytes.
lpBytesReturned [out, optional]
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 call DeviceIoControl 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, call GetOverlappedResult . If hDevice is associated with an I/O completion port, you can retrieve the number of bytes returned by calling GetQueuedCompletionStatus .
lpOverlapped [in, out, optional]
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 valid OVERLAPPED 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.
Return Value
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.
Remarks
To retrieve a handle to the device, you must call the CreateFile function 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 other CreateFile parameters as follows when opening a device handle:
The fdwCreate parameter must specify OPEN_EXISTING.
The hTemplateFile parameter must be NULL.
The fdwAttrsAndFlags parameter can specify FILE_FLAG_OVERLAPPED to indicate that the returned handle can be used in overlapped (asynchronous) I/O operations.
For lists of supported control codes, see the following topics:
Communications Control Codes
Device Management Control Codes
Directory Management Control Codes
Disk Management Control Codes
File Management Control Codes
Power Management Control Codes
Volume Management Control Codes
Examples
For an example that uses DeviceIoControl, see Calling DeviceIoControl
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
CreateEvent
CreateFile
Device Input and Output Control (IOCTL)
GetOverlappedResult
GetQueuedCompletionStatus
OVERLAPPED
Send comments about this topic to Microsoft
Build date: 7/30/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa363216(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:17:46