日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

CTL_CODE说明

發(fā)布時(shí)間:2023/12/10 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CTL_CODE说明 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
我們?cè)谡f(shuō)DeviceIoControl函數(shù)時(shí)其第二個(gè)參數(shù)dwIoControlCode就是由CTL_CODE宏定義的,下邊我們可以了解一下CTL_CODE的內(nèi)容。 CTL_CODE:用于創(chuàng)建一個(gè)唯一的32位系統(tǒng)I/O控制代碼,這個(gè)控制代碼包括4部分組成:DeviceType(設(shè)備類型,高16位(16-31位)),Access(訪問(wèn)限制,14-15位),Function(功能2-13位),Method(I/O訪問(wèn)內(nèi)存使用方式)。

This macro creates a unique system I/O control code (IOCTL).

#define CTL_CODE(DeviceType, Function, Method, Access) (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) )

Parameters(參數(shù))

DeviceType
Defines the type of device for the given IOCTL.

This parameter can be no bigger than a WORD value.

The values used by Microsoft are in the range 0-32767; the values 32768-65535 are reserved for use by OEMs and IHVs.

The following device types are defined by the system:

  • FILE_DEVICE_BEEP
  • FILE_DEVICE_CD_ROM
  • FILE_DEVICE_CD_ROM_FILE_SYSTEM
  • FILE_DEVICE_CONTROLLER
  • FILE_DEVICE_DATALINK
  • FILE_DEVICE_DFS
  • FILE_DEVICE_DISK
  • FILE_DEVICE_DISK_FILE_SYSTEM
  • FILE_DEVICE_FILE_SYSTEM
  • FILE_DEVICE_INPORT_PORT
  • FILE_DEVICE_KEYBOARD
  • FILE_DEVICE_MAILSLOT
  • FILE_DEVICE_MIDI_IN
  • FILE_DEVICE_MIDI_OUT
  • FILE_DEVICE_MOUSE
  • FILE_DEVICE_MULTI_UNC_PROVIDER
  • FILE_DEVICE_NAMED_PIPE
  • FILE_DEVICE_NETWORK
  • FILE_DEVICE_NETWORK_BROWSER
  • FILE_DEVICE_NETWORK_FILE_SYSTEM
  • FILE_DEVICE_NULL
  • FILE_DEVICE_PARALLEL_PORT
  • FILE_DEVICE_PHYSICAL_NETCARD
  • FILE_DEVICE_PRINTER
  • FILE_DEVICE_SCANNER
  • FILE_DEVICE_SERIAL_MOUSE_PORT
  • FILE_DEVICE_SERIAL_PORT
  • FILE_DEVICE_SCREEN
  • FILE_DEVICE_SOUND
  • FILE_DEVICE_DEVICE_STREAMS
  • FILE_DEVICE_TAPE
  • FILE_DEVICE_TAPE_FILE_SYSTEM
  • FILE_DEVICE_TRANSPORT
  • FILE_DEVICE_UNKNOWN
  • FILE_DEVICE_VIDEO
  • FILE_DEVICE_VIRTUAL_DISK
  • FILE_DEVICE_WAVE_IN
  • FILE_DEVICE_WAVE_OUT
  • FILE_DEVICE_8042_PORT
  • FILE_DEVICE_NETWORK_REDIRECTOR
  • FILE_DEVICE_BATTERY
  • FILE_DEVICE_BUS_EXTENDER
  • FILE_DEVICE_MODEM
  • FILE_DEVICE_VDM
  • FILE_DEVICE_MASS_STORAGE
  • FILE_DEVICE_SMB
  • FILE_DEVICE_KS
  • FILE_DEVICE_CHANGER
  • FILE_DEVICE_SMARTCARD
  • FILE_DEVICE_ACPI
  • FILE_DEVICE_DVD
  • FILE_DEVICE_FULLSCREEN_VIDEO
  • FILE_DEVICE_DFS_FILE_SYSTEM
  • FILE_DEVICE_DFS_VOLUME

The following device types are specific to Windows CE:

  • FILE_DEVICE_HAL
  • FILE_DEVICE_CONSOLE
  • FILE_DEVICE_PSL
  • FILE_DEVICE_SERVICE
Function
Defines an action within the device category.

Function codes 0-2047 are reserved for Microsoft; codes 2048-4095 are reserved for OEMs and IHVs.

A function code can be no larger then 4095.

Method
Defines the method codes for how buffers are passed for I/O and file system controls.

The following values are possible for this parameter:

  • METHOD_BUFFERED
  • METHOD_IN_DIRECT
  • METHOD_OUT_DIRECT
  • METHOD_NEITHER

This field is ignored by Windows CE. You should always use the METHOD_BUFFERED value unless compatibility with Windows-based desktop platforms is required using a different?Method?value.

Access
Defines the access check value for any access.

The following table shows the possible flags for this parameter. The FILE_ACCESS_ANY is generally the correct value.

FlagDescription
FILE_ANY_ACCESSRequest all access.
FILE_READ_ACCESSRequest read access. Can be used with FILE_WRITE_ACCESS.
FILE_WRITE_ACCESSRequest write access. Can be used with FILE_READ_ACCESS.

Return Values(返回值)

None.

Remarks(備注)

The macro can be used for defining IOCTL and FSCTL function control codes. All IOCTLs must be defined this way to ensure that values used by Microsoft, OEMs, and IHVs do not overlap.

The following illustration shows the format of the resulting IOCTL.

?

舉例說(shuō)明一下:

我定義兩個(gè)IOCTL,一個(gè)用于對(duì)設(shè)備的讀,一個(gè)用于對(duì)設(shè)備的寫

#define ATST2004_IOCTL_READ CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_READ_DATA)
#define ATST2004_IOCTL_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x801, METHOD_BUFFERED, FILE_WRITE_DATA)

在VC中使用不需要進(jìn)行處理,假如我要在VB中使用這兩個(gè)IOCTL,就需要進(jìn)行查值計(jì)算了,計(jì)算后定義如下:

Private Const ATST2004_IOCTL_READ = &H226000
Private Const ATST2004_IOCTL_WRITE = &H22A004

關(guān)于Method(I/O訪問(wèn)內(nèi)存使用方式),我們下篇在說(shuō)。

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)

總結(jié)

以上是生活随笔為你收集整理的CTL_CODE说明的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。