//+-------------------------------------------------------------------------
//
// Microsoft Windows
//
// Copyright (C) Microsoft Corporation, 1995 - 1997
//
// File: lib.cpp
//
// Contents: helper functions
//
//--------------------------------------------------------------------------
#include "pch.cpp"
#pragma hdrstop
#include "lib.h"
BOOL
ConvertWszToBstr(
OUT BSTR *pbstr,
IN WCHAR const *pwc,
IN LONG cb)
{
BOOL fOk = FALSE;
BSTR bstr;
do
{
bstr = NULL;
if (NULL != pwc)
{
if (-1 == cb)
{
cb = wcslen(pwc) * sizeof(WCHAR);
}
bstr = SysAllocStringByteLen((char const *) pwc, cb);
if (NULL == bstr)
{
break;
}
}
if (NULL != *pbstr)
{
SysFreeString(*pbstr);
}
*pbstr = bstr;
fOk = TRUE;
} while (FALSE);
return(fOk);
}