Microsoft SDK for Java

stringToCoTaskMem

This method of the DllLib class copies a string into a native memory block by using either ANSI or Unicode format depending on the auto mode setting. The memory block is allocated by using the Win32 function CoTaskMemAlloc.

Syntax

public static int stringToCoTaskMem(String s);

Return Value

Returns a pointer to the block that contains the string in the specified format.

Parameters

s The string to copy.

Remarks

You can use the freeCoTaskMem method to release the block from Java.

Important Note   On Windows NT, if you use the stringToCoTaskMem method with the Comctl32.ListView_InsertColumn function, you might not get the results you expect. Instead, you should use the stringToCoTaskAnsi method as shown in the following example:

lvc1.pszText = DllLib.stringToCoTaskMemAnsi("C Column"); // Notice the Ansi suffix
int1 = Comctl32.ListView_InsertColumn(hWindLV1, 1, lvc1);

© 1999 Microsoft Corporation. All rights reserved. Terms of use.