当前位置: 首页>>代码示例>>C++>>正文


C++ ReleaseStr函数代码示例

本文整理汇总了C++中ReleaseStr函数的典型用法代码示例。如果您正苦于以下问题:C++ ReleaseStr函数的具体用法?C++ ReleaseStr怎么用?C++ ReleaseStr使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ReleaseStr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LocLoadFromResource

extern "C" HRESULT DAPI LocLoadFromResource(
    __in HMODULE hModule,
    __in_z LPCSTR szResource,
    __out WIX_LOCALIZATION** ppWixLoc
    )
{
    HRESULT hr = S_OK;
    LPVOID pvResource = NULL;
    DWORD cbResource = 0;
    LPWSTR sczXml = NULL;
    IXMLDOMDocument* pixd = NULL;

    hr = ResReadData(hModule, szResource, &pvResource, &cbResource);
    ExitOnFailure(hr, "Failed to read theme from resource.");

    hr = StrAllocStringAnsi(&sczXml, reinterpret_cast<LPCSTR>(pvResource), 0, CP_UTF8);
    ExitOnFailure(hr, "Failed to convert XML document data from UTF-8 to unicode string.");

    hr = XmlLoadDocument(sczXml, &pixd);
    ExitOnFailure(hr, "Failed to load theme resource as XML document.");

    hr = ParseWxl(pixd, ppWixLoc);
    ExitOnFailure(hr, "Failed to parse WXL.");

LExit:
    ReleaseObject(pixd);
    ReleaseStr(sczXml);

    return hr;
}
开发者ID:AnalogJ,项目名称:Wix3.6Toolset,代码行数:30,代码来源:locutil.cpp

示例2: CheckLoggingPolicy

static void CheckLoggingPolicy(
    __out DWORD *pdwAttributes
    )
{
    HRESULT hr = S_OK;
    HKEY hk = NULL;
    LPWSTR sczLoggingPolicy = NULL;

    hr = RegOpen(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Policies\\Microsoft\\Windows\\Installer", KEY_READ, &hk);
    if (SUCCEEDED(hr))
    {
        hr = RegReadString(hk, L"Logging", &sczLoggingPolicy);
        if (SUCCEEDED(hr))
        {
            LPCWSTR wz = sczLoggingPolicy;
            while (*wz)
            {
                if (L'v' == *wz || L'V' == *wz)
                {
                    *pdwAttributes |= BURN_LOGGING_ATTRIBUTE_VERBOSE;
                }
                else if (L'x' == *wz || L'X' == *wz)
                {
                    *pdwAttributes |= BURN_LOGGING_ATTRIBUTE_EXTRADEBUG;
                }

                ++wz;
            }
        }
    }

    ReleaseStr(sczLoggingPolicy);
    ReleaseRegKey(hk);
}
开发者ID:HesenWolfi,项目名称:wix3,代码行数:34,代码来源:logging.cpp

示例3: WixShellExec

extern "C" UINT __stdcall WixShellExec(
    __in MSIHANDLE hInstall
    )
{
    Assert(hInstall);
    HRESULT hr = S_OK;
    UINT er = ERROR_SUCCESS;
    LPWSTR pwzTarget = NULL;

    hr = WcaInitialize(hInstall, "WixShellExec");
    ExitOnFailure(hr, "failed to initialize");

    hr = WcaGetFormattedProperty(L"WixShellExecTarget", &pwzTarget);
    ExitOnFailure(hr, "failed to get WixShellExecTarget");

    WcaLog(LOGMSG_VERBOSE, "WixShellExecTarget is %ls", pwzTarget);

    if (!pwzTarget || !*pwzTarget)
    {
        hr = E_INVALIDARG;
        ExitOnFailure(hr, "failed to get WixShellExecTarget");
    }

    hr = ShellExec(pwzTarget, FALSE);
    ExitOnFailure(hr, "failed to launch target");

LExit:
    ReleaseStr(pwzTarget);

    if (FAILED(hr)) 
    {
        er = ERROR_INSTALL_FAILURE;
    }
    return WcaFinalize(er); 
}
开发者ID:firegiant,项目名称:wix4,代码行数:35,代码来源:shellexecca.cpp

示例4: CabExtractOpen

static __callback INT_PTR FAR DIAMONDAPI CabExtractOpen(__in_z PSTR pszFile, __in int oflag, __in int pmode)
{
    HRESULT hr = S_OK;
    INT_PTR pFile = -1;
    LPWSTR sczCabFile = NULL;

    // if FDI asks for some unusual mode (in low memory situation it could ask for a scratch file) fail
    if ((oflag != (/*_O_BINARY*/ 0x8000 | /*_O_RDONLY*/ 0x0000)) || (pmode != (_S_IREAD | _S_IWRITE)))
    {
        hr = E_OUTOFMEMORY;
        ExitOnFailure(hr, "FDI asked for a scratch file to be created, which is unsupported");
    }

    hr = StrAllocStringAnsi(&sczCabFile, pszFile, 0, CP_UTF8);
    ExitOnFailure(hr, "Failed to convert UTF8 cab file name to wide character string");

    pFile = reinterpret_cast<INT_PTR>(::CreateFileW(sczCabFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL));
    if (INVALID_HANDLE_VALUE == reinterpret_cast<HANDLE>(pFile))
    {
        ExitWithLastError1(hr, "failed to open file: %ls", sczCabFile);
    }

    if (vdw64EmbeddedOffset)
    {
        hr = CabExtractSeek(pFile, 0, 0);
        ExitOnFailure1(hr, "Failed to seek to embedded offset %I64d", vdw64EmbeddedOffset);
    }

LExit:
    ReleaseStr(sczCabFile);

    return FAILED(hr) ? -1 : pFile;
}
开发者ID:BMurri,项目名称:wix3,代码行数:33,代码来源:cabutil.cpp

示例5: CpiPartitionRolesRead

HRESULT CpiPartitionRolesRead(
    CPI_PARTITION_LIST* pPartList,
    CPI_PARTITION_ROLE_LIST* pPartRoleList
    )
{
    HRESULT hr = S_OK;
    PMSIHANDLE hView, hRec;
    CPI_PARTITION_ROLE* pItm = NULL;
    LPWSTR pwzData = NULL;

    // loop through all application roles
    hr = WcaOpenExecuteView(vcsPartitionRoleQuery, &hView);
    ExitOnFailure(hr, "Failed to execute view on ComPlusPartitionRole table");

    while (S_OK == (hr = WcaFetchRecord(hView, &hRec)))
    {
        // create entry
        pItm = (CPI_PARTITION_ROLE*)::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CPI_PARTITION_ROLE));
        if (!pItm)
            ExitFunction1(hr = E_OUTOFMEMORY);

        // get key
        hr = WcaGetRecordString(hRec, prqPartitionRole, &pwzData);
        ExitOnFailure(hr, "Failed to get key");
        StringCchCopyW(pItm->wzKey, countof(pItm->wzKey), pwzData);

        // get partition
        hr = WcaGetRecordString(hRec, prqPartition, &pwzData);
        ExitOnFailure(hr, "Failed to get application");

        hr = CpiPartitionFindByKey(pPartList, pwzData, &pItm->pPartition);
        if (S_FALSE == hr)
            hr = HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
        ExitOnFailure1(hr, "Failed to find partition, key: %S", pwzData);

        // get name
        hr = WcaGetRecordFormattedString(hRec, prqName, &pwzData);
        ExitOnFailure(hr, "Failed to get name");
        StringCchCopyW(pItm->wzName, countof(pItm->wzName), pwzData);

        // add entry
        if (pPartRoleList->pFirst)
            pItm->pNext = pPartRoleList->pFirst;
        pPartRoleList->pFirst = pItm;
        pItm = NULL;
    }

    if (E_NOMOREITEMS == hr)
        hr = S_OK;

LExit:
    // clean up
    if (pItm)
        FreePartitionRole(pItm);

    ReleaseStr(pwzData);

    return hr;
}
开发者ID:BMurri,项目名称:wix3,代码行数:59,代码来源:cppartrolesched.cpp

示例6: RunRunOnce

static HRESULT RunRunOnce(
    __in_z_opt LPCWSTR wzCommandLine,
    __in int nCmdShow
    )
{
    HRESULT hr = S_OK;
    LPWSTR sczNewCommandLine = NULL;
    LPWSTR sczBurnPath = NULL;
    HANDLE hProcess = NULL;
    int argc = 0;
    LPWSTR* argv = NULL;

    // rebuild the command line without the runonce switch
    if (wzCommandLine && *wzCommandLine)
    {
        argv = ::CommandLineToArgvW(wzCommandLine, &argc);
        ExitOnNullWithLastError(argv, hr, "Failed to get command line.");

        for (int i = 0; i < argc; ++i)
        {
            if (!((argv[i][0] == L'-' || argv[i][0] == L'/') && CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_RUNONCE, -1)))
            {
                PathCommandLineAppend(&sczNewCommandLine, argv[i]);
            }
        }
    }

    // and re-launch
    hr = PathForCurrentProcess(&sczBurnPath, NULL);
    ExitOnFailure(hr, "Failed to get current process path.");

    hr = ProcExec(sczBurnPath, 0 < sczNewCommandLine ? sczNewCommandLine : L"", nCmdShow, &hProcess);
    ExitOnFailure1(hr, "Failed to re-launch bundle process after RunOnce: %ls", sczBurnPath);

LExit:
    if (argv)
    {
        ::LocalFree(argv);
    }

    ReleaseHandle(hProcess);
    ReleaseStr(sczNewCommandLine);
    ReleaseStr(sczBurnPath);

    return hr;
}
开发者ID:Alyoshak,项目名称:wix3,代码行数:46,代码来源:engine.cpp

示例7: FreeUserInApplicationRole

static void FreeUserInApplicationRole(
    CPI_USER_IN_APPLICATION_ROLE* pItm
    )
{
    ReleaseStr(pItm->pwzAccount);

    ::HeapFree(::GetProcessHeap(), 0, pItm);
}
开发者ID:BMurri,项目名称:wix3,代码行数:8,代码来源:cpapprolesched.cpp

示例8: ApprovedExesUninitialize

extern "C" void ApprovedExesUninitialize(
    __in BURN_APPROVED_EXES* pApprovedExes
    )
{
    if (pApprovedExes->rgApprovedExes)
    {
        for (DWORD i = 0; i < pApprovedExes->cApprovedExes; ++i)
        {
            BURN_APPROVED_EXE* pApprovedExe = &pApprovedExes->rgApprovedExes[i];

            ReleaseStr(pApprovedExe->sczId);
            ReleaseStr(pApprovedExe->sczKey);
            ReleaseStr(pApprovedExe->sczValueName);
        }
        MemFree(pApprovedExes->rgApprovedExes);
    }
}
开发者ID:BMurri,项目名称:wix3,代码行数:17,代码来源:approvedexe.cpp

示例9: DAPI_

DAPI_(void) BalInfoUninitialize(
    __in BAL_INFO_BUNDLE* pBundle
    )
{
    for (DWORD i = 0; i < pBundle->packages.cPackages; ++i)
    {
        ReleaseStr(pBundle->packages.rgPackages[i].sczDisplayName);
        ReleaseStr(pBundle->packages.rgPackages[i].sczDescription);
        ReleaseStr(pBundle->packages.rgPackages[i].sczId);
    }

    ReleaseMem(pBundle->packages.rgPackages);

    ReleaseStr(pBundle->sczName);
    ReleaseStr(pBundle->sczLogVariable);
    memset(pBundle, 0, sizeof(BAL_INFO_BUNDLE));
}
开发者ID:FernandoNunes,项目名称:wix3,代码行数:17,代码来源:balinfo.cpp

示例10: FreePartitionUser

static void FreePartitionUser(
    CPI_PARTITION_USER* pItm
    )
{
    ReleaseStr(pItm->pwzAccount);

    ::HeapFree(::GetProcessHeap(), 0, pItm);
}
开发者ID:firegiant,项目名称:wix4,代码行数:8,代码来源:cppartsched.cpp

示例11: FreeUserInPartitionRole

static void FreeUserInPartitionRole(
    CPI_USER_IN_PARTITION_ROLE* pItm
    )
{
    ReleaseStr(pItm->pwzAccount);

    ::HeapFree(::GetProcessHeap(), 0, pItm);
}
开发者ID:BMurri,项目名称:wix3,代码行数:8,代码来源:cppartrolesched.cpp

示例12: StrAnsiAllocFormattedArgs

/********************************************************************
StrAnsiAllocFormattedArgs - allocates or reuses dynamic ANSI string memory
and formats it with the passed in args

NOTE: caller is responsible for freeing ppsz even if function fails
********************************************************************/
extern "C" HRESULT DAPI StrAnsiAllocFormattedArgs(
	__inout LPSTR* ppsz,
	__in LPCSTR szFormat,
	__in va_list args
	)
{
	Assert(ppsz && szFormat && *szFormat);

	HRESULT hr = S_OK;
	DWORD_PTR cch = *ppsz ? MemSize(*ppsz) / sizeof(CHAR) : 0;
	LPSTR pszOriginal = NULL;
	DWORD cchOriginal = 0;

	if (*ppsz)
	{
		cch = MemSize(*ppsz);  // get the count in bytes so we can check if it failed (returns -1)
		if (-1 == cch)
			ExitOnFailure(hr = E_INVALIDARG, "failed to get size of destination string");
		cch /= sizeof(CHAR);  //convert the count in bytes to count in characters

		cchOriginal = lstrlenA(*ppsz);
	}

	if (0 == cch)   // if there is no space in the string buffer
	{
		cch = 256;
		hr = StrAnsiAlloc(ppsz, cch);
		ExitOnFailure1(hr, "failed to allocate string to format: %s", szFormat);
	}

	// format the message (grow until it fits or there is a failure)
	do
	{
		hr = StringCchVPrintfA(*ppsz, cch, szFormat, args);
		if (STRSAFE_E_INSUFFICIENT_BUFFER == hr)
		{
			if (!pszOriginal)
			{
				// this allows you to pass the original string as a formatting argument and not crash
				// save the original string and free it after the printf is complete
				pszOriginal = *ppsz;
				*ppsz = NULL;
				// StringCchVPrintfW starts writing to the string...
				// NOTE: this hack only works with sprintf(&pwz, "%s ...", pwz, ...);
				pszOriginal[cchOriginal] = 0;
			}
			cch *= 2;
			hr = StrAnsiAlloc(ppsz, cch);
			ExitOnFailure1(hr, "failed to allocate string to format: %S", szFormat);
			hr = S_FALSE;
		}
	} while (S_FALSE == hr);
	ExitOnFailure(hr, "failed to format string");

LExit:
	ReleaseStr((void*) pszOriginal);
	return hr;
}
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:64,代码来源:strutil.cpp

示例13: ScaVirtualDirsUninstall7

HRESULT ScaVirtualDirsUninstall7(
                                 __in SCA_VDIR7* psvdList
                                 )
{

    HRESULT hr = S_OK;
    SCA_VDIR7* psvd = psvdList;
    LPWSTR wzPath = NULL;

    while (psvd)
    {
        if (WcaIsUninstalling(psvd->isInstalled, psvd->isAction))
        {
            //init path
            hr = StrAllocFormatted(&wzPath, L"/%s", psvd->wzVDirRoot);
            ExitOnFailure(hr, "Failed to create vdir path");

            if (psvd->fHasApplication)
            {
                //delete Application
                hr = ScaWriteConfigID(IIS_APPLICATION);
                ExitOnFailure(hr, "Failed to write app ID ");
                hr = ScaWriteConfigID(IIS_DELETE);
                ExitOnFailure(hr, "Failed to write delete app ID ");
#pragma prefast(suppress:26037, "Source string is null terminated - it is populated as target of ::StringCchCopyW")
                hr = ScaWriteConfigString(psvd->wzWebName);        //site name key
                ExitOnFailure(hr, "Failed to write App site Name");
#pragma prefast(suppress:26037, "Source string is null terminated - it is populated as target of ::StringCchCopyW")
                hr = ScaWriteConfigString(wzPath);                 //  App Path
                ExitOnFailure(hr, "Failed to write app path root ");
                hr = ScaWriteConfigString(L"NOP");                 //  App pool
                ExitOnFailure(hr, "Failed to write app path app pool ");
            }
            else
            {
                //delete VDir
                hr = ScaWriteConfigID(IIS_VDIR);
                ExitOnFailure(hr, "Failed to write vDir ID ");
                hr = ScaWriteConfigID(IIS_DELETE);
#pragma prefast(suppress:26037, "Source string is null terminated - it is populated as target of ::StringCchCopyW")
                hr = ScaWriteConfigString(psvd->wzWebName);        //site name key
                ExitOnFailure(hr, "Failed to write App site Name");
                hr = ScaWriteConfigString(wzPath);                 //  Vdir Path
                ExitOnFailure(hr, "Failed to write app vdir ");
                hr = ScaWriteConfigString(L"NOP");                 //  Phy Path
                ExitOnFailure(hr, "Failed to write vdir path");
            }

            ExitOnFailure(hr, "Failed to remove VirtualDir '%ls' from config", psvd->wzKey);
        }

        psvd = psvd->psvdNext;
    }

LExit:
    ReleaseStr(wzPath);
    return hr;
}
开发者ID:firegiant,项目名称:wix4,代码行数:58,代码来源:scavdir7.cpp

示例14: action

/******************************************************************
 WixRollbackInternetShortcuts - entry point for Internet shortcuts
    custom action (rollback)
*******************************************************************/
extern "C" UINT __stdcall WixRollbackInternetShortcuts(
    __in MSIHANDLE hInstall
)
{
    HRESULT hr = S_OK;
    UINT er = ERROR_SUCCESS;

    LPWSTR pwz = NULL;
    LPWSTR pwzCustomActionData = NULL;
    LPWSTR pwzShortcutPath = NULL;
    int iAttr = 0;

    // initialize
    hr = WcaInitialize(hInstall, "WixRemoveInternetShortcuts");
    ExitOnFailure(hr, "failed to initialize WixRemoveInternetShortcuts");

    hr = WcaGetProperty(L"CustomActionData", &pwzCustomActionData);
    ExitOnFailure(hr, "failed to get CustomActionData");

    // loop through all the custom action data
    pwz = pwzCustomActionData;
    while (pwz && *pwz)
    {
        // extract the custom action data we're interested in
        hr = WcaReadStringFromCaData(&pwz, &pwzShortcutPath);
        ExitOnFailure(hr, "failed to read shortcut path from custom action data for rollback");

        // delete file
        hr = FileEnsureDelete(pwzShortcutPath);
        ExitOnFailure1(hr, "failed to delete file '%ls'", pwzShortcutPath);

        // skip over the shortcut target and attributes
        hr = WcaReadStringFromCaData(&pwz, &pwzShortcutPath);
        ExitOnFailure(hr, "failed to skip shortcut target from custom action data for rollback");
        hr = WcaReadIntegerFromCaData(&pwz, &iAttr);
        ExitOnFailure(hr, "failed to read shortcut attributes from custom action data");
    }

LExit:
    ReleaseStr(pwzCustomActionData);
    ReleaseStr(pwzShortcutPath);

    er = FAILED(hr) ? ERROR_INSTALL_FAILURE : er;
    return WcaFinalize(er);
}
开发者ID:BMurri,项目名称:wix3,代码行数:49,代码来源:netshortcuts.cpp

示例15: PayloadsUninitialize

extern "C" void PayloadsUninitialize(
    __in BURN_PAYLOADS* pPayloads
    )
{
    if (pPayloads->rgPayloads)
    {
        for (DWORD i = 0; i < pPayloads->cPayloads; ++i)
        {
            BURN_PAYLOAD* pPayload = &pPayloads->rgPayloads[i];

            ReleaseStr(pPayload->sczKey);
            ReleaseStr(pPayload->sczFilePath);
            ReleaseMem(pPayload->pbHash);
            ReleaseMem(pPayload->pbCertificateRootThumbprint);
            ReleaseMem(pPayload->pbCertificateRootPublicKeyIdentifier);
            ReleaseStr(pPayload->sczSourcePath);
            ReleaseStr(pPayload->sczLocalFilePath);
            ReleaseStr(pPayload->downloadSource.sczUrl);
            ReleaseStr(pPayload->downloadSource.sczUser);
            ReleaseStr(pPayload->downloadSource.sczPassword);
        }
        MemFree(pPayloads->rgPayloads);
    }

    // clear struct
    memset(pPayloads, 0, sizeof(BURN_PAYLOADS));
}
开发者ID:firegiant,项目名称:wix4,代码行数:27,代码来源:payload.cpp


注:本文中的ReleaseStr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。