windows-nt/Source/XPSP1/NT/base/win32/fusion/installer/includes/util.h

45 lines
836 B
C
Raw Normal View History

2020-09-26 03:20:57 -05:00
#undef SAFEDELETE
#define SAFEDELETE(p) if ((p) != NULL) { delete (p); (p) = NULL; };
#undef SAFEDELETEARRAY
#define SAFEDELETEARRAY(p) if ((p) != NULL) { delete[] (p); (p) = NULL; };
#undef SAFERELEASE
#define SAFERELEASE(p) if ((p) != NULL) { (p)->Release(); (p) = NULL; };
inline
WCHAR*
WSTRDupDynamic(LPCWSTR pwszSrc)
{
LPWSTR pwszDest = NULL;
if (pwszSrc != NULL)
{
const DWORD dwLen = lstrlenW(pwszSrc) + 1;
pwszDest = new WCHAR[dwLen];
if( pwszDest )
memcpy(pwszDest, pwszSrc, dwLen * sizeof(WCHAR));
}
return pwszDest;
}
inline
LPBYTE
MemDupDynamic(const BYTE *pSrc, DWORD cb)
{
LPBYTE pDest = NULL;
pDest = new BYTE[cb];
if(pDest)
memcpy(pDest, pSrc, cb);
return pDest;
}
HRESULT
RemoveDirectoryAndChildren(LPWSTR szDir);