Compartilhar via


System.Gadget.Settings.read 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 value of unspecified type associated with a gadget Settings key.

Syntax

retVal = System.Gadget.Settings.read(
  strName
)

Parameters

strName [in]

String that specifies the name of the Settings key.

Return value

The value of the Settings key. The data type of the returned value will default to String if it cannot be coerced into one of the following: Boolean, Floating-point, Floating-point, or Integer.

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.read("settingsSelectionIndex");
        // Update gadget UI based on user Settings selection.
        UpdateSelection(selectionIndex);
    }
    // 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
Header
Corecrt_io.h
IDL
Sidebar.idl
DLL
Sidebar.Exe (version 1.00 or later)

See also

System.Gadget.Settings

readString