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

  • Thread starter Thread starter Academia
  • Start date Start date
A

Academia

I want to declare in vb:

FSCTL_GET_COMPRESSION

FSCTL_SET_COMPRESSION

which are declared in Winioctl.h.



#define FSCTL_GET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 15,
METHOD_BUFFERED, FILE_ANY_ACCESS)

#define FSCTL_SET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16,
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?
 
I want to declare in vb:
FSCTL_GET_COMPRESSION
FSCTL_SET_COMPRESSION
which are declared in Winioctl.h.
but I can't figure out what the numerical value is.
Do you know how to do that?

an internet search yielded:

0x0009003C, FSCTL_GET_COMPRESSION
0x0009C040, FSCTL_SET_COMPRESSION
 
Academia said:
I want to declare in vb:

FSCTL_GET_COMPRESSION

FSCTL_SET_COMPRESSION

which are declared in Winioctl.h.

#define FSCTL_GET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 15,
METHOD_BUFFERED, FILE_ANY_ACCESS)

#define FSCTL_SET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16,
METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)

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

\\\

' 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
///
 
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 don't know about :-)


Thanks


Herfried K. Wagner said:
Academia said:
I want to declare in vb:

FSCTL_GET_COMPRESSION

FSCTL_SET_COMPRESSION

which are declared in Winioctl.h.

#define FSCTL_GET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 15,
METHOD_BUFFERED, FILE_ANY_ACCESS)

#define FSCTL_SET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16,
METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)

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

\\\

' 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
///
 
Academia said:
What is "Private Function CTL_CODE"?
Is that a function you wrote?

Yes, it's a translation of the 'CTL_CODE' C macro which is used in the
header file to construct the defines' values.
Is there a macro in the .h file that does that for C programs?

Yes:

\\\
#define CTL_CODE( DeviceType, Function, Method, Access ) ( \
((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
)
///
 
thanks again

Herfried K. Wagner said:
Yes, it's a translation of the 'CTL_CODE' C macro which is used in the
header file to construct the defines' values.


Yes:

\\\
#define CTL_CODE( DeviceType, Function, Method, Access )
( \
((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method)
\
)
///
 
Back
Top