Click or drag to resize

MemComp Function

X#
Compare bytes in two memory buffers.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION MemComp(
	ptrFirst AS IntPtr,
	ptrSecond AS IntPtr,
	dwCount AS DWORD
) AS LONG
Request Example 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: DWord
The number of bytes to compare.

Return Value

Type: Long
-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#
1MemComp() compares the ANSI values of the first <paramref name="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 ).<br />
2The system only uses the ANSI set.
Examples
This examples use MemComp():
X#
 1FUNCTION Compare()
 2    LOCAL pszC1 := "abc" AS PSZ
 3    LOCAL pszC2 := "abcd" AS PSZ
 4    LOCAL pszChar1 := "ä" AS PSZ
 5    LOCAL pszChar2 := "ß" AS PSZ
 6    ? MemComp(pszC1, pszC2, 4)                // -1
 7    ? MemComp(pszC2, pszC1, 4)                //  1
 8    // The ANSI value of "ä" is greater than "ß"
 9    // although its OEM value is less.
10    ? MemComp(pszChar1, pszChar2)            //  1
See Also