pp_bitclear()

Clears a bit in a bit field

Applies to:

Win32, Win64

Syntax-VB:

Declare Function pp_bitclear(ByRef bit_field As Long, ByVal bit_number As Long) As Long

Syntax-C:

LONG pp_bitclear(LPLONG bit_field, LONG bit_number)

Arguments:

<bit_field> is a bit field variable to work on, passed by reference

<bit_number> is the bit number in the bit field to clear, 1 to 32

Returns:

The new value of the bit field with the selected bit cleared.

Description:

There are several long integers in the License File that may be used as bit-fields. A bit field contains 32 bits that can be used to store the state of binary attributes. The state of those attributes are either enabled or disabled. This is typically used to license various modules or features on a pay-per-module basis.

This function along with pp_bittest() and pp_bitset() work together to provide you with total bit field manipulation capability.

Example:

' use a Trigger Code to disable a particular menu option

' assigns bit 5 to menu option 1

Global Const MENUOPTION_1 = 5

 

Sub get_code()

Dim month As Long, day As Long, year As Long

Dim ce_num As Long, unlock_code As Long

Dim result As Long, comp_no As Long

Dim bit_field As Long

 

' Get a valid code entry and computer number

ce_num = pp_cenum

comp_no = pp_compno COMPNO_BIOS, "", ""

 

print "Code entry number: " & Str( ce_num )

print "Computer ID: " & Str( comp_no )

print "Enter a code: "

input unlock_code

 

' decode the number entered and see if it is valid

result = pp_tcode( unlock_code, ce_num, comp_no, 400 )

 

' now, see if a correct code was entered and process it

Select Case result

 Case 1

  ' disable the menu option #1

  pp_getvarnum lfhandle, VAR_UDEF_NUM_2, bit_field

  pp_bitclear bit_field, MENUOPTION_1

  pp_setvarnum lfhandle, VAR_UDEF_NUM_2, bit_field

 

 case 2

  ' enable the menu option #1

  pp_getvarnum lfhandle, VAR_UDEF_NUM_2, bit_field

  pp_bitset bit_field, MENUOPTION_1

  pp_setvarnum lfhandle, VAR_UDEF_NUM_2, bit_field

 

 Case 3

  .. .. ..

 

 Case Else

  MsgBox "Invalid Code Entered", 0, "Trigger Codes"

 

End Select

See Also:

PP_BITTEST(), and PP_BITSET()

Concept Link IconRelated Topics