Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ResUtilExpandEnvironmentStrings function

Expands strings containing unexpanded references to environment variables. The PRESUTIL_EXPAND_ENVIRONMENT_STRINGS type defines a pointer to this function.

Syntax


LPWSTR WINAPI ResUtilExpandEnvironmentStrings(
  _In_ LPCWSTR pszSrc
);

typedef LPWSTR (WINAPI *PRESUTIL_EXPAND_ENVIRONMENT_STRINGS)(
    _In_ LPCWSTR pszSrc
);

Parameters

pszSrc [in]

Pointer to a null-terminated Unicode string containing unexpanded references to environment variables (an expandable string).

Return value

If the operation succeeds, the function returns a pointer to the expanded string (REG_EXPAND_SZ). The function allocates the necessary memory with LocalAlloc. To prevent memory leaks, be sure to release the memory with LocalFree.

If the operation fails, the function returns NULL. For more information, call GetLastError.

Examples

The following example calls ResUtilExpandEnvironmentStrings to expand the %SystemRoot% environment variable. This example uses the ClusDocEx.h header file defined in the Failover Cluster documentation.


#include "ClusDocEx.h"

int main( void )
{
    WCHAR  pszExpand[]  = L"%SystemRoot%";
    LPWSTR lpszExpanded = NULL;
    int    intStatus    = 0;

    // The function allocates the necessary memory.
    lpszExpanded = ResUtilExpandEnvironmentStrings( pszExpand );

    if( lpszExpanded != NULL )
    {
        wprintf( L"System root is: %ls\n", lpszExpanded );
    }
    else
    {
        ErrorMsg( GetLastError(), L"String expansion failed." ); // Declared in clushead.h
        intStatus = 1;
    }

    // Always
    LocalFree( lpszExpanded );

    return intStatus;
}


Requirements

Minimum supported client

None supported

Minimum supported server

Windows Server 2008 Enterprise, Windows Server 2008 Datacenter

Header

ResApi.h

Library

ResUtils.lib

DLL

ResUtils.dll

See also

ResUtilGetExpandSzValue
ResUtilFindExpandSzProperty
ResUtilGetEnvironmentWithNetName

 

 

Show: