Jump to content

wpSaveString

From EDM2

This instance method is called to allow the object to save an ASCIIZ instance data string.

Syntax

_wpSaveString(somSelf, pszClass, ulKey, pszValue)

Parameters

somSelf (WPObject *) - input
Pointer to the object on which the method is being invoked.
Points to an object of class WPObject.
pszClass (PSZ) - input
Pointer to the class name.
A pointer to a zero-terminated string that contains any unique string. The class name is recommended but not enforced.
ulKey (ULONG) - input
Class-defined identifier.
A class-defined identifier that correlates to a particular instance data variable.
pszValue (PSZ) - input
String to be stored.

Returns

rc (BOOL) - returns
Success indicator.
TRUE: Successful completion.
FALSE: Error occurred.

Remarks

The saved ASCIIZ string can be restored by issuing a call to wpRestoreString.

Usage

This method can be called only during the processing of the wpSaveState method.

How to Override

This method is generally not overridden.

Example Code

This example demonstrates an override of wpRestoreState method to save string data.

SOM_Scope BOOL   SOMLINK wpRestoreState(nbk   somSelf,
ULONG ulReserved)
{
BOOL fSuccess;      / Success flag /
ULONG ulCount;      / Length of title string /
UCHAR uchName[40];   / Buffer for title */

nbkData *somThis = nbkGetData(somSelf);
nbkMethodDebug("nbk","wpRestoreState");

ulCount = 40L;                              /* Size of input buffer */
fSuccess = _wpRestoreString ( somSelf      /* Self pointer */
                           , (PSZ) "nbk"       /* Class name */
                           , WPNBK_KEY         /* Key for data */
                           , &uchName           /* String to receive data */
                           , &ulCount    );   /* Amount of data returned */

if ( !fSuccess ) {   /* First time object is being restored */

    // initialize string to NULL
    strcpy ( uchName, "" );

    // save initial string to ini file
    _wpSaveString ( somSelf             /* Self pointer */
                  , (PSZ) "nbk"         /* Class name */
                  , WPNBK_KEY           /* Key of data */
                  , uchName   );        /* String to write */
}

_UserSetTitle ( somSelf, uchName );   /* Set an instance variable */

return (parent_wpRestoreState(somSelf,ulReserved));

}

Related Methods