Partager via


System.Gadget.Settings.readString method

[The Windows Gadget Platform/Sidebar is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. ]

Retrieves a stored String value associated with a gadget Settings key.

Syntax

strRetVal = System.Gadget.Settings.readString(
  strName
)

Parameters

strName [in]

String that specifies or receives the name of the Settings key.

Return value

The String value of the Settings key.

Remarks

Use readString for performance and efficiency reasons if the data type is a String.

There is a 1024 character limit for Settings keys and a 2048 character limit for Settings values; values longer than these limits will be truncated.

Use write or writeString to store Settings values.

The Settings values are unique for each user account, even if the same gadget is used.

Examples

The following example demonstrates how to retrieve a Settings value into a gadget variable.

// --------------------------------------------------------------------
// Handle the Settings dialog closed event.
// event = Event argument.
// --------------------------------------------------------------------
function SettingsClosed(event)
{
    // User hit OK on the settings page.
    if (event.closeAction == event.Action.commit)
    {
        userEntry = 
            System.Gadget.Settings.readString("settingsUserEntry");
        // Update gadget UI based on user Settings input.
        SetContentText(userEntry);
    }
    // User hit Cancel on the settings page.
    else if (event.closeAction == event.Action.cancel)
    {
        SetContentText("canceled");
    }
}

Requirements

Minimum supported client
Windows Vista [desktop apps only]
Minimum supported server
Windows Server 2008 [desktop apps only]
End of client support
Windows 7
End of server support
Windows Server 2008
IDL
Sidebar.idl
DLL
Sidebar.Exe (version 1.00 or later)

See also

System.Gadget.Settings

writeString