Condividi tramite


LoadString

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function loads a string resource from the executable file associated with a specified module, copies the string into a buffer, and appends a terminating null character.

Syntax

int LoadString(
  HINSTANCE hInstance,
  UINT uID,
  LPTSTR lpBuffer,
  int cchBufferMax
);

Parameters

  • hInstance
    [in] Handle to an instance of the module whose executable file contains the string resource.
  • uID
    [in] Integer identifier of the string to be loaded.
  • lpBuffer
    [out] Long pointer to the buffer to receive the string.
  • cchBufferMax
    [in] Size of the buffer in characters. The string is truncated and null terminated if it is longer than the number of characters specified.

Return Value

The number of characters copied into the buffer, excluding the terminating null character, indicates success. Zero indicates that the string resource does not exist. To get extended error information, call GetLastError.

Remarks

If lpBuffer is set to NULL, the return value is a pointer to the requested string. The caller should cast the return value to an LPCTSTR. This pointer points directly to the resource, so the string is read-only. The length of the string, not including any terminating null character, can be found in the word preceding the string.

To use the lpBuffer pointer, the **–**n flag must be set with the resource compiler, RC.

Note

String resources are not null-terminated by default. When lpBuffer is set to NULL, verify whether the string resource represented by the pointer returned by LoadString is null-terminated, and if necessary, append a terminating null character to the resource before using it in your application.

Requirements

Header winbase.h
Library Loadstr.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

String Functions

Other Resources

LoadAccelerators
LoadBitmap
LoadIcon
LoadMenu
Programming with Unicode and NLS