Accessing Device Drivers from C#
By David Union, April 01, 2002
Device Drivers are written largely in C or C++. No explicit support for Device Driver communication is included in the current .NET framework. David implements support with C# and discusses how to access Win32 APIs using the Platform Invocation Services and how to make that reusable from within the .NET framework with Overloading.
April 2002/ Accessing Device Drivers from C#
Example 7
CTL_CODE and DEVICE_TYPE_FROM_CTL_CODE
public static int CTL_CODE(int DeviceType, int Function, int Method,
int Access) {
return
(((DeviceType) << 16)|((Access) << 14)|((Function) << 2)|(Method));
}
public int DEVICE_TYPE_FROM_CTL_CODE(int ctrlCode) {
return (int)(( ctrlCode & 0xffff0000) >> 16) ;
}