Click or drag to resize

MemComp Function

Compare bytes in two memory buffers.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.10
Syntax
 FUNCTION MemComp(
	ptrFirst AS IntPtr,
	ptrSecond AS IntPtr,
	dwCount AS DWORD
) AS LONG
View Source

Parameters

ptrFirst
Type: IntPtr
A pointer to the first memory buffer.
ptrSecond
Type: IntPtr
A pointer to the second memory buffer.
dwCount
Type: UInt32
The number of bytes to compare.

Return Value

Type: Int32
-1, 0, or 1 if the first <dwCount> bytes of <ptrFirst> are less than, equal to, or greater than the first <dwCount> bytes of <ptrSecond>, respectively.
Remarks
X#
MemComp() compares the ANSI values of the first <dwCount> bytes in each memory buffer.  Note that some characters (such as ä can have a greater ANSI value but a lower OEM value than other characters (such as ).  The system only uses the ANSI set.
Examples
This examples use MemComp():
X#
FUNCTION Compare()
        LOCAL pszC1 := "abc" AS PSZ
        LOCAL pszC2 := "abcd" AS PSZ
        LOCAL pszChar1 := "ä" AS PSZ
        LOCAL pszChar2 := "ß" AS PSZ
        ? MemComp(pszC1, pszC2, 4)                                // -1
        ? MemComp(pszC2, pszC1, 4)                                //  1
        // The ANSI value of "ä" is greater than "ß"
        // although its OEM value is less.
        ? MemComp(pszChar1, pszChar2)                        //  1
See Also