Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Please post this to the profox.ro (Romanian) forum
Message
From
18/10/2006 10:00:19
 
 
To
17/10/2006 16:43:41
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01162716
Message ID:
01162930
Views:
11
Olaf Doschke and others very generously responded with the following:
> #define CTL_CODE( DeviceType, Function, Method, Access ) 
> (                 \
>    ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) 
> \

This cryptic #define makes 32 bits constants as follows:

dddd dddd dddd dddd aaff ffff ffff ffmm

Legend:
d: DeviceType
a: Access
f: Function
m: Method

You can construct the constant in this simpler way:

CTL_CODE = DeviceType * 65536 + Function * 4 + Method + Access * 16384


> #define IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER CTL_CODE(IOCTL_STORAGE_BASE, 
> 0x0304, METHOD_BUFFERED, FILE_ANY_ACCESS)

In the above, we have these constants:

IOCTL_STORAGE_BASE = 0x0000002d, or 45 decimal
METHOD_BUFFERED = 0
FILE_ANY_ACCESS = 0

So, IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER would be:

CTL_CODE = DeviceType * 65536 + Function * 4 + Method + Access * 16384
= 45 * 65536 + 0x0304 * 4 + 0 + 0 * 16384
= 45 * 65536 + 772 * 4
= 2952208, or 0x002D0C10

> In the above example, how was the value of parameter 0x2D1400 determined?

See the bits distribution above. When 0x002D1400 is broken down, you get:

DeviceType = 0x002D
Access = 0
Function = 0x1400 / 4 = 0x500 or 1280 decimal
Method = 0

I couldn't find any constant for 0x500, so it's either for later versions of 
Windows, or undocumented.
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform