Declare Statements for Function and Sub Procedures
Available in VG32.DLL
Instructions: Use these statements as needed in VB Code to declare
routines in VG32.DLL.
Create a separate .BAS module and paste the contents between the marker lines, then edit out unneeded routines.
MARKER: BEGINNING OF MODULE, DO NOT INCLUDE THIS LINE
Attribute VB_Name = "VG32DLLDeclares"
' FILE Y:\MCM\VC\VC6\VG32\VG32DECL.BAS
' for use in 32-Bit versions of VB, VBA, or ACCESS
' UPDATED for VG32.dll v. 2.5 11/16/00
' You should place VG32.DLL in the windows system directory
' (e.g., on some systems C:\WINNT\System32 or C:\Windows\System32)
' VG32.DLL is a standard (non-OLE) DLL compiled most recently with VC++ 6.0
' Notes to developer when VG32.DLL is revised or new procedures added:
' Always do the following
' Be sure that all parameters passed where C++ expects a pointer
' are passed ByRef (default) and those expecting a value are passed ByVal
' Pass all strings ByVal (this appends CHR$(0))
' Return value of all Boolean functions (e.g., VgIsDigit%) is 0 or -1
' ADD New Procedure to DEF file
' REBUILD ALL
' COPY the new VG32.DLL to windows system 32 directory, e.g., C:\WINNT\System32
' UPDATE the declare statements in this file
Option Explicit
DefLng A-Z
' BIT MANIPULATION PROCEDURES [from Module VG1]:
' Note that low bit position = 0, highest position value for Integer is 15 and for long integer 1s 31
' Possible bit values are 0 or 1
Declare Function VgGetBitI% Lib "VG32.dll" (ByVal IntIn%, ByVal BitPosn%)
' IntIn%: may have any integer value but probably should be >0
' BitPosn%: is bit position (0 = far right low bit) & should be 0-15
' Returns: value of that bit (or 0 if n >= 16
Declare Function VgSetBitI% Lib "VG32.dll" (ByVal IntIn%, ByVal BitPosn%, ByVal Value%)
' IntIn%: may have any integer value but probably should be 0 - 32767
' BitPosn%: is bit position (0 = far right low bit) & should be 0-15
' Value%: should be 0 or 1. If neither, it is treated as 1.
' Returns: value of IntIn% with bit BitPosn% set to Value%
Declare Function VgGetBitsI% Lib "VG32.dll" (ByVal IntIn%, ByVal BitPosn%, ByVal NumBits%)
' IntIn%: may have any integer value but probably should be 0 - 32767
' BitPosn%: is starting bit position (0 = far right low bit) & should be 0 - 15
' NumBits%: is number of bits to read starting on the right at BitPosn% position
' & including bits to the left. Should be in range 1 to 16 - BitPosn%
' Returns: value of bits at positions BitPosn% to BitPosn% + NumBits% in IntIn%
' if BitPosn% + NumBits% <= 16, or undefined if BitPosn% + NumBits% > 16
Declare Function VgSetBitsI% Lib "VG32.dll" (ByVal IntIn%, ByVal StartPosn%, ByVal NumBits%, ByVal Value%)
' IntIn%: may have any integer value but probably should be >0
' StartPosn%: is starting bit position (0 = far right low bit) & should be 0 - 15
' NumBits%: is number of bits to modify starting at StartPosn% position
' & including bits to the left. Should be in range 1 to 16 - StartPosn%
' Value%: should be 0 to 2^NumBits%-1 (i.e., having no more than NumBits% bits)
' Excess high bits are stripped and ignored.
' Note that Value% is not limited to 0 or 1 but may potentially be -32768 to 32767
' Returns: value of IntIn% with bits StartPosn% to StartPosn% + NumBits% set to Value%
' if in-range arguments, or undefined otherwise
Declare Function VgGetBitL% Lib "VG32.dll" (ByVal LongIn&, ByVal BitPosn%)
' LongIn&: may have any long integer value but probably should be > 0
' BitPosn%: is bit position (0 = far right low bit) & should be 0-31 (assuming 32 bit long)
' Returns: value of bit BitPosn% in LongIn& (or 0 if BitPosn% >= 32)
Declare Function VgSetBitL& Lib "VG32.dll" (ByVal LongIn&, ByVal BitPosn%, ByVal Value%)
' LongIn&: may have any long integer value but probably should be >0
' BitPosn%: is bit position (0 = far right low bit) & should be 0-31 (assuming 32 bit long)
' Value%: should be 0 or 1. If neither, it is treated as 1.
' Returns: value of LongIn& with bit BitPosn% set to Value%
Declare Function VgGetBitsL& Lib "VG32.dll" (ByVal LongIn&, ByVal BitPosn%, ByVal NumBits%)
' LongIn&: may have any long value but probably should be >0
' BitPosn%: is starting bit position (0 = far right low bit) & should be 0 - 31
' NumBits%: is number of bits to read starting at BitPosn% position
' & including bits to the left. Should be in range 1 to 32 - BitPosn%
' Returns: value of bits at positions BitPosn% to BitPosn% + NumBits% in LongIn& if BitPosn% + NumBits% <= 32,
' or undefined if BitPosn% + NumBits% > 32
Declare Function VgSetBitsL& Lib "VG32.dll" (ByVal LongIn&, ByVal StartPosn%, ByVal NumBits%, ByVal Value&)
' LongIn&: may have any long value but probably should be > 0
' StartPosn%: is starting bit position (0 = far right low bit) & should be 0 - 31
' NumBits%: is number of bits to modify starting at StartPosn% position
' & including bits to the left. Should be in range 1 to 32 - StartPosn%
' Value&: should be 0 to 2^NumBits%-1 (i.e., having no more than NumBits% bits)
' Excess high bits are stripped and ignored.
' Returns: value of LongIn& with bits StartPosn% to StartPosn% + NumBits% set to Value& if in-range arguments, or
' undefined otherwise
Declare Function VgRShiftI% Lib "VG32.dll" (ByVal IntIn%, ByVal HowMany%)
' IntIn%: may have any integer value
' HowMany%: number of right shifts to perform (should be 0-15
' Returns: value of IntIn% shifted HowMany% bits to the right, with 0's added
' on the left, or undefined but probably 0 if HowMany% > 15
' Equivalent to integer division by 2^HowMany%
Declare Function VgLShiftI% Lib "VG32.dll" (ByVal IntIn%, ByVal HowMany%)
' IntIn%: may have any integer value
' HowMany%: number of left shifts to perform (should be 0-15)
' Returns: value of IntIn% shifted HowMany% bits to the left, with 0's added
' on the right, or undefined but probably 0 if HowMany% > 15
' Equivalent to multiplication by 2^HowMany%
Declare Function VgRShiftL& Lib "VG32.dll" (ByVal LongIn&, ByVal HowMany%)
' LongIn&: may have any long integer value
' HowMany%: number of right shifts to perform (should be 0-31
' Returns: value of LongIn& shifted HowMany% bits to the right, with 0's added
' on the left, or undefined but probably 0 if HowMany% > 31
' Equivalent to integer division by 2^HowMany%
Declare Function VgLShiftL& Lib "VG32.dll" (ByVal LongIn&, ByVal HowMany%)
' LongIn&: may have any long integer value
' HowMany%: number of left shifts to perform (should be 0-31)
' Returns: value of LongIn& shifted HowMany% bits to the left, with 0's added
' on the right, or undefined but probably 0 if HowMany% > 31
' Equivalent to multiplication by 2^HowMany%
Declare Function VgToggleBitI% Lib "VG32.dll" (ByVal IntIn%, ByVal BitPosn%)
' IntIn%: may have any integer value
' BitPosn%: is bit position (0 = far right low bit) & should be 0-15
' Returns: value of IntIn% with bit BitPosn% XOR'd
Declare Function VgToggleBitL& Lib "VG32.dll" (ByVal LongIn&, ByVal BitPosn%)
' LongIn&: may have any long integer value
' BitPosn%: is bit position (0 = far right low bit) & should be 0-31
' Returns: value of LongIn& with bit BitPosn% XOR'd
' INTEGER MANIPULATION PROCEDURES [from Module VG2]
Declare Function VgMaxI% Lib "VG32.dll" (ByVal i%, ByVal j%)
' i% and j%: may have any integer values
' Returns: whichever is greater (closer to +32767)
Declare Function VgMinI% Lib "VG32.dll" (ByVal i%, ByVal j%)
' i% and j%: may have any integer values
' Returns: whichever is smaller (closer to -32768)
Declare Function VgMaxL& Lib "VG32.dll" (ByVal i&, ByVal j&)
' i& and j&: may have any integer values
' Returns: whichever is greater (closer to 2,147,483,647)
Declare Function VgMinL& Lib "VG32.dll" (ByVal i&, ByVal j&)
' i& and j&: may have any integer values
' Returns: whichever is smaller (closer to -2,147,483,648)
Declare Sub VgSwapI Lib "VG32.dll" (i%, j%)
' i% and j%: may have any integer values
' Swaps values stored at addresses i% and j%
Declare Sub VgSwapL Lib "VG32.dll" (i&, j&)
' i&, j&: may have any long integer values
' Swaps values stored at addresses i& and j&
Declare Function VgSwapBytesI% Lib "VG32.dll" (ByVal i%)
' Adapted from Desaware APIGDI32.DLL
' i%: may have any integer value
' Swaps the order of bytes in i%
' Ie, for i% containing bytes A-B, returns B-A
Declare Function VgSwapWordsL& Lib "VG32.dll" (ByVal L&)
' Adapted from Desaware APIGDI32.DLL
' L&: may have any long integer value
' Swaps the order of words (i.e., the high and low 16-bit portions) in L&
' after the bytes in each 16-bit word are swapped
' Ie, for L& containing bytes A-B-C-D, returns D-C-B-A
Declare Sub VgIncrI Lib "VG32.dll" (i%)
' i%: may have any integer value
' Adds 1 to i% (no effect if i% = 32767)
Declare Sub VgDecrI Lib "VG32.dll" (i%)
' i%: may have any integer value
' Subtracts 1 from i% (no effect if i% = -32768)
Declare Sub VgIncrL Lib "VG32.dll" (i&)
' i&: may have any long integer value
' Adds 1 to i% (no effect if i% = 2,147,483,647)
Declare Sub VgDecrL Lib "VG32.dll" (i&)
' i&: may have any long integer value
' Subtracts 1 from i& (no effect if i& = -2,147,483,648)
Declare Function VgInRangeI% Lib "VG32.dll" (ByVal Value%, ByVal Min%, ByVal Max%)
' Value%: may have any integer value
' Min%: may have any integer value but should be < Max%
' Max%: may have any integer value but should be > Min%
' Returns -1 if Min% <= Value% and Value% <= Max%, otherwise 0
Declare Function VgInRangeL% Lib "VG32.dll" (ByVal Value&, ByVal Min&, ByVal Max&)
' Value&: may have any long integer value
' Min&: may have any long integer value but should be < Max&
' Max&: may have any long integer value but should be > Min&
' Returns -1 if Min& <= Value& and Value& <= Max&, otherwise 0
Declare Function Vg32DLLMajorVersion& Lib "VG32.dll" ()
' Returns the major version of this DLL. Added version c. 2.2
' You should test this and the minor version to see if you have an up-to-date DLL
' E.g., versions preceding version 2.2 do not have VgCopyData, VgGetLongFromAddress,
' and VgGetAddressForObject, VgSwapBytesI%, and VgSwapBytesL&
Declare Function Vg32DLLMinorVersion& Lib "VG32.dll" ()
' Returns the minor version of this DLL. Added version c. 2.2
' See comments with Vg32DLLMajorVersion&
' STRING AND CHARACTER MANIPULATION PROCEDURE [from Module VG3]:
Declare Function VgIsAlpha% Lib "VG32.dll" (ByVal AscChar%)
' AscChar% is a integer with value 0-255
' Returns -1 if CHR$(AscChar%) is a letter (i.e., in the range "a"-"z" or "A"-"Z"),
' or 0 otherwise
Declare Function VgIsDigit% Lib "VG32.dll" (ByVal AscChar%)
' AscChar% is a integer with value 0-255
' Returns -1 if CHR$(AscChar%) is a base-10 digit (i.e., in the range "0" - "9"),
' or 0 otherwise
Declare Function VgIsHexDigit% Lib "VG32.dll" (ByVal AscChar%)
' AscChar% is a integer with value 0-255
' Returns -1 if CHR$(AscChar%) is a hexadecimal digit
' (i.e., in the range "0" - "9" or "A" - "F"), or 0 otherwise
Declare Function VgIsBlackWin% Lib "VG32.dll" (ByVal AscChar%) ' Returns 0 or -1
' AscChar% is a integer with value 0-255
' Returns: -1 if CHR$(AscChar%) is printable and visible as such in WinWord-ANSI
' 0 otherwise
Declare Function VgInstrRev% Lib "VG32.dll" (ByVal Lookin$, ByVal Ascii%)
' LookIn$: The string to search
' Ascii%: Integer with value 0-255 representing the single character CHR$(Ascii%)
' for which to search for the last occurrence in LookIn$
' Returns: 0 if not found, or if LookIn$ is Zero-Length, or if Ascii% = 0,
' otherwise returns the position of the last occurrence of CHR$(Ascii%)
' and having a possible rage of values 1 - LEN(LookIn$)
' Note that the return value = 1 for the first char on the left, not 0
Declare Function VgPosnLastBS& Lib "VG32.dll" (ByVal Lookin$) ' added v. 2.5
' LookIn$: The string to search for the last backslash in
' Returns: 0 if no backslash found, or if LookIn$ is Zero-Length
' otherwise returns the position of the last occurrence of backslash
' Note that the return value = 1 for the first char on the left, not 0
Declare Function VgStripRange& Lib "VG32.dll" (ByVal St$, ByVal LowLimit%, ByVal HighLimit%)
' St$: The input string may include characters with Asc(Char) values 1-255
' but must not contain any internal CHR$(0)'s (i.e., Asc(Char) = 0)
' (Use VgStripRange0 if the string may contain internal CHR$(0)'s)
' LowLimit%, HighLimit%: Integer values representing the lowest and highest ANSI/Ascii
' values of a range of chars to strip from the string
' For example, use LowLimit%=1, HighLimit%=31 to remove control characters
' or use LowLimit%=128, HighLimit%=255 to remove non-ASCII characters
' Returns: the new length (say, NewLength&) of the stripped string excluding the terminal CHR$(0)
' St$ has been changed and must be truncated with St$ = Left$(St$, NewLength&)
Declare Function VgStripRange0& Lib "VG32.dll" (ByVal St$, ByVal LowLimit%, ByVal HighLimit%, ByVal StLen&)
' St$: The input string may include all characters with Asc(Char) values 0-255
' and may contain internal CHR$(0)'s (i.e., Asc(Char) = 0)
' LowLimit%, HighLimit%: Integer values representing the lowest and highest ANSI/Ascii
' values of a range of chars to strip from the string
' For example, use LowLimit%=0, HighLimit%=31 to remove all control characters
' or use LowLimit%=128, HighLimit%=255 to remove non-ASCII characters
' StLen&: The length in bytes of St$ (i.e., Len(St$))
' Returns: the new length (say, NewLength&) of the stripped string excluding the terminal CHR$(0)
' St$ has been changed and must be trunctated with St$ = Left$(St$, NewLength&)
Declare Function VgStripChars Lib "VG32.dll" (ByVal St$, ByVal WhichChars$) As Long
' St$: The input string may include characters with Asc(Char) values 1-255
' but cannot contain internal CHR$(0)'s (i.e., Asc(Char) = 0)
' It may be zero-lenth
' WhichChars$: A string of characters. All occurrences of each and every character
' in this string are to be removed from St$
' It may be zero-lenth
' The order of characters in this string is irrelevant
' Returns: the new length (say, NewLength&) of the stripped string excluding the terminal CHR$(0)
' St$ has been changed and must be trunctated with St$ = Left$(St$, NewLength&)
Declare Function VgBinToDec& Lib "VG32.dll" (ByVal OnesAndZeros$)
' OnesAndZeros$: A string of <= 32 characters (not counting the final CHR$(0)
' where each character is either "1" (CHR$(49) or "0" (CHR$(48))
' and representing a negative or positive 32-bit long [signed] integer value.
' If there are more than 32 characters, the most significant (left-most)
' 32 characters are processed and the others are ignored.
' Chars other than "1" or "0" terminate reading the string but previously read
' characters are retained.
' Returns: the negative or positive signed long integer having
' the equivalent binary value of OnesAndZeros$
Declare Function VgMidAsc% Lib "VG32.dll" (ByVal St$, ByVal CharPosn%)
' St$: The input string (should not be zero-length but may contain internal CHR$(0)'s
' CharPosn%: The character position for which to return a value
' The first character is assumed to have position 1, not 0
' You must not allow CharPosn% to be greater than Len(St$) or less than 1
' Returns: The value of the character at position CharPosn%
' (i.e., equivalent to Asc(Mid$(St$,CharPosn%,1))
' or -1 if CharPosn% < 1
' If CharPosn% > Len(St$), results are undefined and program crash may result
' MISCELLANEOUS PROCEDURES [from Module VGMisc]:
Declare Function VgGetAddressForObject& Lib "VG32.dll" (Object As Any)
' Adapted from Desaware APIGDI32.DLL, Added in Version 2.2
' Object: Any object or variable, passed ByRef
' Returns: the numeric value of the address of the Object
' Note: In C++, received as LPVOID and returned cast as (Long)
Declare Function VgGetLongFromAddress& Lib "VG32.dll" (ByVal lpLongValue&)
' Adapted from Desaware APIGDI32.DLL, Added in Version 2.2
' lpLongValue&: Numeric value of address of a long integer
' It must be passed ByVal
' Typically derived from an API call or VgGetAddressForObject
' Returns: value of the long integer (i.e., *lpLongValue in C++)
Declare Sub VgCopyData Lib "VG32.dll" (Source As Any, Dest As Any, ByVal NumBytes&)
' Adapted from Desaware APIGDI32.DLL, calls the C++ run-time memmove(Dest, Source, NumBytes)
' Added in Version 2.2
' Source: Any variable, passed ByRef (e.g., a long integer or UDT)
' Dest: Any variable, passed ByRef (e.g., a long integer or UDT)
' NumBytes&: The number of bytes to copy
' Typically (but not always), it should be <= Len(Source) and <= Len(Dest)
' Action: Copies Numbytes& consecutive bytes in memory from Source to Dest
' Note: in C++, Source and Dest are received as LPVOID
Declare Sub VgCopyDataBynum Lib "VG32.dll" Alias "VgCopyData" (ByVal Source&, ByVal Dest&, ByVal nCount&)
' Adapted from Desaware APIGDI32.DLL, calls VgCopyData, Added in Version 2.2
' Source&: Numeric value of a memory address, e.g. of a source variable
' It must be passed ByVal
' Typically derived from an API call or VgGetAddressForObject
' Dest&: : Numeric value of memory address, e.g. of a destination variable
' It must be passed ByVal
' Typically derived from an API call or VgGetAddressForObject&
' NumBytes&: The number of bytes to copy
' Typically (but not always),
' it should be <= Length in bytes of the Source variable whose address is source&
' and <= Length in bytes of the Dest variable whose address is Dest&
' Action: Copies Numbytes& consecutive bytes in memory
' from memory address Source& to memory address Dest&
' API-RELATED FILE/KEY TIME AND DATE PROCEDURES
' File times for NT files and read into WIN32_FIND_DATA data structures
' in FILETIME fields ftLastAccessTime etc. are stored in 64 presumably unsigned bits as the number
' of 100 nanosecond intervals that have elapsed since January 1, 1601.
' Therefore, subtracting a newer (larger file time) file date from an older file time would yield
' a negative value ostensibly earlier than January 1, 1601 and probably meaningless
' Use the API function CompareFileTime to see which is the newer file before using VGSubtractFileTimes
' FILETIME file times can be converted to DOS date and time with API FileTimeToDosDateTime
' DOS date and time file times can be converted to FILETIME with API DosDateTimeToFileTime
' File times increment in 2 second increments for FAT16 drives but 100 nanosec increments for NTFS
Declare Sub VGAddFileTimes Lib "VG32.dll" (F1 As Any, F2 As Any, F3 As Any)
' Adapted from Desaware APIGDI32.DLL 12/28/96, first added version 2.4
' Input: f1, f2 are FILETIMEs
' Output: f3 is also a FILETIME containing the number of 100 nanosecond intervals that
' are obtained by adding f2 to f1 (stored in a high 32-bit and low 32-bit longs)
Declare Function VGConvertFileTimeToDouble Lib "VG32.dll" (F1 As Any) As Double
' Adapted from Desaware APIGDI32.DLL 12/28/96, first added version 2.4
' Input: f1 is a FILETIME
' Returns: f1 contains to a double precision amount containing the number of
' 100 nanosecond intervals that were stored in f1 in high 32-bit and low 32-bit longs.
Declare Sub VGConvertDoubleToFileTime Lib "VG32.dll" (ByVal d As Double, F1 As Any)
' Adapted from Desaware APIGDI32.DLL 12/28/96, first added version 2.4
' Input: d is a double precision value representing the number of 100 nanosecond intervals
' Output: f1 is a FILETIME in which the input has been converted to a filetime
' in which 100 nanosecond intervals are stored in high 32-bit and low 32-bit longs.
Declare Sub VGNegateFileTime Lib "VG32.dll" (F1 As Any)
' Adapted from Desaware APIGDI32.DLL 12/28/96, first added version 2.4
' Input: f1 is a FILETIME
' Output: f1 now contains the same file time as the input negated
Declare Sub VGSubtractFileTimes Lib "VG32.dll" (F1 As Any, F2 As Any, F3 As Any)
' CAUTION: Can produce meaningless results if subtracting
' newer larger file time) file from older file!
' Therefore, should use API CompareFileTime to determine which is newer or just DONT USE.
' Adapted from Desaware APIGDI32.DLL 12/28/96, first added version 2.4
' Input: F1, F2 are FILETIMEs
' Output: F3 is also a FILETIME containing the number of 100 nanosecond intervals that
' are obtained by subtracting F2 from F1 (i.e., F3 = F1 - F2)
' (result is stored in high 32-bit and low 32-bit longs)
MARKER: END OF MODULE, DO NOT INCLUDE THIS LINE