Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How does vb take out the address data and copy it as it is?
How does vb take out the address data and copy it as it is?
private Declare Sub copy memory Lib " kernel 32 " Alias " RtlMoveMemory " u

(The target is arbitrary, the source is arbitrary, and the length of ByVal is Long)

-The following routine implements the split and merge operations of integer variables.

The public function Con(ByVal HiByte is byte, ByVal LoByte is byte) is an integer.

Concatenate two bytes into a word.

Input-

High byte The high byte participating in the link.

Low byte of "LoByte" participating in the link.

Output-

Returns the linked results.

Liu Qi last updated 2004-3-20.

Dim iRet is an integer.

The function varptr () is used: get the address of the variable.

Copy memory ByVal VarPtr(iRet), LoByte, 1

Copy memory ByVal VarPtr(iRet)+1, high byte, 1

Con = iRet

End function

The public function ConWord(ByVal HiWord is an integer, ByVal LoWord is an integer) is a long integer.

Connect two words into DWord.

Input-

HiWord participates in the high-level words of the link.

● Word participation link

Output-

Returns the linked results.

Liu Qi last updated 2004-3-20.

As long as Dim lRet

Copy memory ByVal VarPtr(lRet), low word, 2

Copy memory ByVal VarPtr(lRet)+2, HiWord, 2

ConWord = lRet

End function

As a common function of bytes, hi (as long as byval words)

Take the high byte of a word.

Input-

Words (words)

Output-

Returns the high byte of the Word parameter.

Liu Qi last updated 2004-3-20.

Dim bytRet As Byte

CopyMemory bytRet, ByVal VarPtr (word)+1, 1

Hi = bytes

End function

The public function Lo(ByVal word is an integer) is a byte.

Take the low byte of a word.

Input-

Words (words)

Output-

Returns the low byte of the Word parameter.

Liu Qi last updated 2004-3-20.

Dim bytRet As Byte

CopyMemory bytRet, ByVal VarPtr (word), 1

Lo = bytes

End function

Public function hiword in integer form (byvaldword length)

Take a high-order word (DWord) of a double word.

Input-

DWord words

Output-

Returns the high word of the DWord parameter.

Liu Qi last updated 2004-3-20.

Dim intRet is an integer.

CopyMemory intRet,ByVal VarPtr(DWord) + 2,2

HiWord = intRet

End function

Public function LoWord(ByVal DWord) in integer form

Take a two-word low-order word (DWord)

Input-

DWord words

Output-

Returns the low word of the DWord parameter.

Liu Qi last updated 2004-3-20.

Dim intRet is an integer.

Copyright intRet, ByVal VarPtr(DWord), 2

LoWord = intRet

End function

-The following routine realizes the shift of plastic variables.

Common function ShLB(ByVal Byt As Byte, optional byval bits num as long =1) as byte.

Byte left shift function

Input-

Byt source operand

Maximum shift number of digits

Output-

Return value shift result

Liu Qi last updated 2004-3-23

Dim I &

For I = 1 to BitsNum

Byt = ShLB _ by 1 bit (bytes)

Next, I

ShLB = Byt

End function

Common function ShRB(ByVal Byt As Byte, optional byval bits num as long =1) as byte.

Byte right shift function

Input-

Byt source operand

Maximum shift number of digits

Output-

Return value shift result

Liu Qi last updated 2004-3-23

Dim I &

For I = 1 to BitsNum

Byt = ShRB _ by 1 bit (bytes)

Next, I

ShRB = bytes

End function

Common function shlb _ by1bit (byval byt as byte) as byte.

A function that shifts the byte to the left by one bit, serving ShlB.

Input-

Byt source operand

Output-

Return value shift result

Liu Qi last updated 2004-3-23

(Byt and&h7f): mask the highest bit. *2: Move one place to the left.

ShLB _ by 1 bit =(Byt And & amp; H7F) * 2

ShlB_By 1Bit = Byt * 2' overflow test

End function

Common function shrb _ by1bit (byval byt as byte) as byte.

A function that shifts the byte to the right by one bit, serving ShrB.

Input-

Byt source operand

Output-

Return value shift result

Liu Qi last updated 2004-3-24

/2: Move one position to the right

ShRB_By 1Bit = Fix(Byt / 2)

End function

The public function ShLW(ByVal Word As Integer, optional byval bits num as long =1) as integer.

Left shift function of the word ""

Input-

Word source operand

Maximum shift number of digits

Output-

Return value shift result

Liu Qi last updated 2004-3-24

Dim I &

For I = 1 to BitsNum

Word = ShLW_By 1Bit (word)

Next, I

ShLW = Word

End function

Common function ShRW(ByVal Word As Integer, optional byval bits num as long =1) as integer.

Right shift function of the word ""

Input-

Word source operand

Maximum shift number of digits

Output-

Return value shift result

Liu Qi last updated 2004-3-24

Dim I &

For I = 1 to BitsNum

Word = ShRW_By 1Bit (word)

Next, I

ShRW = Word

End function

The public function ShLW_By 1Bit(ByVal is an integer) is an integer.

A function that moves a word one bit to the left.

Input-

Word source operand

Output-

Return value shift result

Liu Qi last updated 2004-3-24

Dim high byte is byte, high byte is byte.

Divide a word into bytes

HiByte = Hi (word): LoByte = Lo (word)

The high byte is shifted to the left by one bit to ensure that the highest bit of the low byte is shifted into the lowest bit of the high byte.

Hibyte = shlb _ by1bit (hibyte) or IIf((LoByte And & amp; h80)= & amp; H80 and. H 1。 H0)

Lobyte = shlb _ by1bit (lobyte)' The low byte is shifted one bit to the left.

Recombine the shifted bytes into words.

ShLW_By 1Bit = Con (high byte, high byte)

End function

Private function ShRW_By 1Bit(ByVal is an integer) is an integer.

A function that moves a word one bit to the right.

Input-

Word source operand

Output-

Return value shift result

Liu Qi last updated 2004-3-27

Dim high byte is byte, high byte is byte.

Divide a word into bytes

HiByte = Hi (word): LoByte = Lo (word)

The low byte is shifted one bit to the right to ensure that the lowest shift of the high byte is moved into the highest bit of the low byte.

Lobyte = shrb _ by1bit (lobyte) or IIf((hi byte And & amp; h 1)= & amp; H 1。 H80 and. H0)

Shift the upper byte to the right by one bit,

High byte = ShRB _ by 1 bit (high byte)

Recombine the shifted bytes into words.

ShRW_By 1Bit = Con (high byte, high byte)

End function

The public function ShLD(ByVal DWord length, optional ByVal BitsNum length = 1) length.

Function to shift double words to the left

Input-

DWord source operand

Maximum shift number of digits

Output-

Return value shift result

Liu Qi last updated March 28, 2004

Dim I &

For I = 1 to BitsNum

DWord = ShLD_By 1Bit(DWord)

Next, I

ShLD = DWord

End function

The public function ShRD(ByVal DWord length, optional ByVal BitsNum length = 1) length.

Function to shift double words to the right

Input-

DWord source operand

Maximum shift number of digits

Output-

Return value shift result

Liu Qi last updated March 28, 2004

Dim I &

For I = 1 to BitsNum

DWord = ShRD_By 1Bit(DWord)

Next, I

ShRD = DWord

End function

The public function shld _ by1bit (as long as byvaldword) is the same length.

The function of shifting double words to the left by one bit serves ShlD ().

Input-

DWord source operand

Output-

Return value shift result

Liu Qi last updated March 29, 2004

Dim iHiWord%

Split a double word into two words

ihi word = hi word(DWord):ILO word = LoWord(DWord)

The upper word is shifted to the left by one bit, and the highest bit of the lower word is moved to the lowest bit of the upper word.

Ihiword = shlw _ by1bit (ihiword) or IIf((I word And & amp; h 8000)= & amp; H8000 and. H 1。 H0)

The lower word is shifted one place to the left.

ILoWord = ShLW _ by 1 bit (iloword)

Shld _ by1bit = conword (ihiword, ILO word)' reconnect to the double word and return the result.

End function

The common function SHRD _ by1bit (as long as byvaldword) is the same length.

The function of shifting double words to the right by one bit serves ShrD ().

Input-

DWord source operand

Output-

Return value shift result

Liu Qi last updated March 29, 2004

Dim iHiWord%

Split a double word into two words

ihi word = hi word(DWord):ILO word = LoWord(DWord)

Move the low word to the right by one bit, and move the lowest position of the high word to the highest position of the low word.

Iloword = shrw _ by1bit (iloword) or IIF ((ihiword and&; h 1)= & amp; H 1。 H8000 and. H0)

Move the high-order word one position to the right.

IHiWord = ShRW _ by 1 bit (ihiword)

Shrd _ by1bit = conword (ihiword, iloword)' reconnects into double words and returns the result.

End function

Common function shlb _ c _ by1bit (byval byt as byte) as byte.

Upload byte & gt a function that moves one bit to the left. C stands for cycle, cycle

Input-

Byt: source operand

Output-

Return value: shift result

Liu Qi last updated 2004-8-8

(Byt and&h7f): mask the highest bit. *2: Move one place to the left.

ShLB _ C _ by 1 bit =((Byt And & amp; H7F) * 2) or IIf((Byt and&h80) =&; H80 and. H 1。 H0)

End function

Common function shrb _ c _ by1bit (byval byt as byte) as byte.

Upload byte & gt a function that moves one bit to the right.

Input-

Byt: source operand

Output-

Return value: shift result

Liu Qi last updated 2004-8-8

(Byt and&h7f): mask the highest bit. *2: Move one place to the left.

ShRB_C_By 1Bit = Fix(Byt/2) or IIF ((byt and&; h 1)= & amp; H 1。 H80 and. H0)

End function