.NET Framework - how to get the numerical value of a constant from Winioctl.h

Asked By Academia on 10-Jan-08 10:24 AM
I want to declare in vb:

FSCTL_GET_COMPRESSION

FSCTL_SET_COMPRESSION

which are declared in Winioctl.h.



METHOD_BUFFERED, FILE_ANY_ACCESS)

METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)



but I can't figure out what the numerical value is.



Do you know how to do that?




AMerce replied on 10-Jan-08 10:56 AM
an internet search yielded:

0x0009003C, FSCTL_GET_COMPRESSION
0x0009C040, FSCTL_SET_COMPRESSION
Academia replied on 10-Jan-08 08:03 PM
Thanks
Herfried K. Wagner [MVP] replied on 10-Jan-08 08:31 PM
\\\

' Values taken from "Winioctl.h".
Private Const FILE_DEVICE_FILE_SYSTEM As Int32 = &H9
Private Const METHOD_BUFFERED As Int32 = &H0
Private Const FILE_ANY_ACCESS As Int32 = &H0

Private ReadOnly FSCTL_GET_COMPRESSION As Int32 = _
CTL_CODE( _
FILE_DEVICE_FILE_SYSTEM, _
15, _
METHOD_BUFFERED, _
FILE_ANY_ACCESS _
)

Private Function CTL_CODE( _
ByVal DeviceType As Int32, _
ByVal [Function] As Int32, _
ByVal Method As Int32, _
ByVal Access As Int32 _
) As Int32
Return DeviceType << 16 Or Access << 14 Or [Function] << 2 Or Method
End Function
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Academia replied on 11-Jan-08 10:41 AM
What is "Private Function CTL_CODE"?
Is that a function you wrote?

Is there a macro in the .h file that does that for C programs?

Is there any area of VB.NET that you do not know about :-)


Thanks
Herfried K. Wagner [MVP] replied on 11-Jan-08 07:19 PM
Yes, it's a translation of the 'CTL_CODE' C macro which is used in the
header file to construct the defines' values.


Yes:

\\\
((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
)
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Academia replied on 12-Jan-08 10:00 AM
thanks again