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


C++ StringCbCopyW函数代码示例

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


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

示例1: ConvertOEMDevmode

BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut)
{
    HRESULT hCopy = S_OK;


    if( (NULL == pOEMDevIn)
        ||
        (NULL == pOEMDevOut)
      )
    {
        ERR(DLLTEXT("ConvertOEMDevmode() invalid parameters.\r\n"));
        return FALSE;
    }

    // Check OEM Signature, if it doesn't match ours,
    // then just assume DMIn is bad and use defaults.
    if(pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature)
    {
        VERBOSE(DLLTEXT("Converting private OEM Devmode.\r\n"));

        // Set the devmode defaults so that anything the isn't copied over will
        // be set to the default value.
        pOEMDevOut->bEnabled                = WATER_MARK_DEFAULT_ENABLED;
        pOEMDevOut->dfRotate                = WATER_MARK_DEFAULT_ROTATION;
        pOEMDevOut->dwFontSize              = WATER_MARK_DEFAULT_FONTSIZE;
        pOEMDevOut->crTextColor             = WATER_MARK_DEFAULT_COLOR;
        hCopy = StringCbCopyW(pOEMDevOut->szWaterMark, sizeof(pOEMDevOut->szWaterMark), WATER_MARK_DEFAULT_TEXT);

        // Copy the old structure in to the new using which ever size is the smaller.
        // Devmode maybe from newer Devmode (not likely since there is only one), or
        // Devmode maybe a newer Devmode, in which case it maybe larger,
        // but the first part of the structure should be the same.

        // DESIGN ASSUMPTION: the private DEVMODE structure only gets added to;
        // the fields that are in the DEVMODE never change only new fields get added to the end.

        memcpy(pOEMDevOut, pOEMDevIn, __min(pOEMDevOut->dmOEMExtra.dwSize, pOEMDevIn->dmOEMExtra.dwSize));

        // Re-fill in the size and version fields to indicated 
        // that the DEVMODE is the current private DEVMODE version.
        pOEMDevOut->dmOEMExtra.dwSize       = sizeof(OEMDEV);
        pOEMDevOut->dmOEMExtra.dwVersion    = OEM_VERSION;
    }
    else
    {
        WARNING(DLLTEXT("Unknown DEVMODE signature, pOEMDMIn ignored.\r\n"));

        // Don't know what the input DEVMODE is, so just use defaults.
        pOEMDevOut->dmOEMExtra.dwSize       = sizeof(OEMDEV);
        pOEMDevOut->dmOEMExtra.dwSignature  = OEM_SIGNATURE;
        pOEMDevOut->dmOEMExtra.dwVersion    = OEM_VERSION;
        pOEMDevOut->bEnabled                = WATER_MARK_DEFAULT_ENABLED;
        pOEMDevOut->dfRotate                = WATER_MARK_DEFAULT_ROTATION;
        pOEMDevOut->dwFontSize              = WATER_MARK_DEFAULT_FONTSIZE;
        pOEMDevOut->crTextColor             = WATER_MARK_DEFAULT_COLOR;
        hCopy = StringCbCopyW(pOEMDevOut->szWaterMark, sizeof(pOEMDevOut->szWaterMark), WATER_MARK_DEFAULT_TEXT);
    }

    return SUCCEEDED(hCopy);
}
开发者ID:Realhram,项目名称:wdk81,代码行数:60,代码来源:devmode.cpp

示例2: ProcessArguments

BOOL ProcessArguments(int iArgCnt, WCHAR ** argv)
{
    if(iArgCnt < 2)
        return FALSE;

    wPath[0] = 0;
    wFullUserName[0] = 0;
	memset(wServerName, NULL, sizeof(wServerName));
	memset(wNameSpace, NULL, sizeof(wNameSpace));

    for(int iCnt = 1; iCnt <= iArgCnt-1 ; iCnt++)
    {
        WCHAR * pArg = argv[iCnt];
        if(pArg[0] != '-')
            return FALSE;
        switch (pArg[1])
        {
            case L's':
            case L'S':
                StringCbCopyW(wServerName, sizeof(wServerName), pArg+3);
                break;
            case L'n':
            case L'N':
                StringCbCopyW(wNameSpace, sizeof(wNameSpace), pArg+3);
                break;
            default:
                return FALSE;
        }
    }
    
    return TRUE;
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:32,代码来源:security.cpp

示例3: FormatFs

BOOL FormatFs (int driveNo, int clusterSize, int fsType)
{
	wchar_t dllPath[MAX_PATH] = {0};
	WCHAR dir[8] = { (WCHAR) driveNo + L'A', 0 };
	PFORMATEX FormatEx;
	HMODULE hModule;
	int i;
	WCHAR szFsFormat[16];
	WCHAR szLabel[2] = {0};
	switch (fsType)
	{
		case FILESYS_NTFS:
			StringCbCopyW (szFsFormat, sizeof (szFsFormat),L"NTFS");
			break;
		case FILESYS_EXFAT:
			StringCbCopyW (szFsFormat, sizeof (szFsFormat),L"EXFAT");
			break;
		default:
			return FALSE;
	}

	
	if (GetSystemDirectory (dllPath, MAX_PATH))
	{
		StringCbCatW(dllPath, sizeof(dllPath), L"\\fmifs.dll");
	}
	else
		StringCbCopyW(dllPath, sizeof(dllPath), L"C:\\Windows\\System32\\fmifs.dll");
	
	hModule = LoadLibrary (dllPath);

	if (hModule == NULL)
		return FALSE;

	if (!(FormatEx = (PFORMATEX) GetProcAddress (GetModuleHandle (L"fmifs.dll"), "FormatEx")))
	{
		FreeLibrary (hModule);
		return FALSE;
	}

	StringCbCatW (dir, sizeof(dir), L":\\");

	FormatExError = TRUE;
	
	// Windows sometimes fails to format a volume (hosted on a removable medium) as NTFS.
	// It often helps to retry several times.
	for (i = 0; i < 50 && FormatExError; i++)
	{
		FormatExError = FALSE;
		FormatEx (dir, FMIFS_HARDDISK, szFsFormat, szLabel, TRUE, clusterSize * FormatSectorSize, FormatExCallback);
	}

	// The device may be referenced for some time after FormatEx() returns
	Sleep (4000);

	FreeLibrary (hModule);
	return FormatExError? FALSE : TRUE;
}
开发者ID:makomi,项目名称:VeraCrypt,代码行数:58,代码来源:Format.c

示例4: BLBS_GetIniFullPath

wchar_t* BLBS_GetIniFullPath(wchar_t* iniFullPath, const size_t bufSize)
{
	GetModuleFileNameW(NULL, iniFullPath, bufSize);
	wchar_t* dirPath = StrRChrW(iniFullPath, NULL, L'\\')+1;
	StringCbCopyW(dirPath, bufSize, BL_SettingFile);
	return iniFullPath;
}
开发者ID:ied206,项目名称:BatteryLine,代码行数:7,代码来源:BatStat.c

示例5: mkfulldir

/* create full directory tree. returns 0 for success, -1 if failure */
int
mkfulldir (wchar_t *oriPath, BOOL bCheckonly)
{
	struct _stat st;
	wchar_t *uniq_file;
	wchar_t path [TC_MAX_PATH];

	StringCbCopyW (path, TC_MAX_PATH, oriPath);

	if (wcslen (path) == 3 && path[1] == L':')
		goto is_root;	/* keep final slash in root if present */

	/* strip final forward or backslash if we have one! */
	uniq_file = wcsrchr (path, L'\\');
	if (uniq_file && uniq_file[1] == L'\0')
		uniq_file[0] = L'\0';
	else
	{
		uniq_file = wcsrchr (path, L'/');
		if (uniq_file && uniq_file[1] == L'\0')
			uniq_file[0] = L'\0';
	}

      is_root:
	if (bCheckonly)
		return _wstat (path, &st);

	if (_wstat (path, &st))
		return mkfulldir_internal (path);
	else
		return 0;
}
开发者ID:AB9IL,项目名称:VeraCrypt,代码行数:33,代码来源:Dir.c

示例6: MakeStringCopy

// Allocates and copies source string.
PWSTR MakeStringCopy(HANDLE hHeap, PCWSTR pszSource)
{
    PWSTR   pszCopy = NULL;
    DWORD   dwSize;


    // Validate parameters
    if( (NULL == hHeap)
        ||
        (NULL == pszSource)
      )
    {
        return NULL;
    }

    // Allocate memory for string duplication, and duplicate the string.
    dwSize = (DWORD)(wcslen(pszSource) + 1) * sizeof(WCHAR);
    pszCopy = (PWSTR) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, dwSize);
    if(NULL != pszCopy)
    {
        HRESULT hResult;


        hResult = StringCbCopyW(pszCopy, dwSize, pszSource);
        if(FAILED(hResult))
        {
            HeapFree(hHeap, 0, pszCopy);
            pszCopy = NULL;
            SetLastError(hResult);
        }
    }

    return pszCopy;
}
开发者ID:kcrazy,项目名称:winekit,代码行数:35,代码来源:StringUtils.cpp

示例7: WbemErrorString

//*****************************************************************************
// Function:	WbemErrorString
// Purpose:		Turns sc into a text string
// Note:		The BSTR returned by this method needs to be freed by the caller.
//				If allocation fails, the method will return NULL
//*****************************************************************************
BSTR WbemErrorString(SCODE sc)
{
    IWbemStatusCodeTextPtr pStatus;
    BSTR bstr = NULL;

    SCODE mysc = CoCreateInstance(CLSID_WbemStatusCodeText, 0, CLSCTX_INPROC_SERVER,
        IID_IWbemStatusCodeText, (LPVOID *) &pStatus);

    if (mysc == S_OK)
    {
        mysc = pStatus->GetErrorCodeText(sc, 0, 0, &bstr);
        if (mysc == S_OK)
        {
        }
        else
        {
            WCHAR szBuffer2[MAXITOA];
            WCHAR szBuffer[sizeof(szBuffer2) + 4];

            _ltow_s(sc, szBuffer2, 16);
			StringCbCopyW(szBuffer, sizeof(szBuffer), L"0x");      
			StringCbCatW(szBuffer, sizeof(szBuffer), szBuffer2);
            bstr = SysAllocString(szBuffer);
        }
    }

    return bstr;
}
开发者ID:nizihabi,项目名称:sdk71examples,代码行数:34,代码来源:Utils.Cpp

示例8: thrd_EnterCrit

wchar_t *osi_LogSaveStringW(osi_log_t *logp, wchar_t *s)
{
    wchar_t *saveplace;

    if (!logp) return s;

    if (!logp->enabled) return s;

    if (s == NULL) return NULL;

    thrd_EnterCrit(&logp->cs);

    saveplace = (wchar_t *) (logp->stringsp[logp->stringindex]);

    if (wcslen(s)*sizeof(wchar_t) >= OSI_LOG_STRINGSIZE)
        StringCbPrintfW(saveplace, OSI_LOG_STRINGSIZE, L"...%s",
                        (s + wcslen(s) - (OSI_LOG_STRINGSIZE/sizeof(wchar_t) - 4)));
    else
        StringCbCopyW(saveplace, OSI_LOG_STRINGSIZE, s);

    logp->stringindex++;

    if (logp->stringindex >= logp->maxstringindex)
        logp->stringindex = 0;

    thrd_LeaveCrit(&logp->cs);

    return saveplace;
}
开发者ID:haught,项目名称:openafs,代码行数:29,代码来源:osilog.c

示例9: OEMUICallBack

////////////////////////////////////////////////////////////////////////////////
//
// OptItems call back for OEM device or document property UI.
//
LONG APIENTRY OEMUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam)
{
    LONG    lReturn = CPSUICB_ACTION_NONE;
    POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM;


    VERBOSE(DLLTEXT("OEMUICallBack() entry.\r\n"));

    switch(pCallbackParam->Reason)
    {
        case CPSUICB_REASON_APPLYNOW:
            // Store OptItems state in DEVMODE.
            pOEMDev->bEnabled = !pOEMUIParam->pOEMOptItems[0].Sel;
            if(FAILED(StringCbCopyW(pOEMDev->szWaterMark, sizeof(pOEMDev->szWaterMark), (LPWSTR)pOEMUIParam->pOEMOptItems[1].pSel)))
            {
                ERR(DLLTEXT("OEMUICallBack() failed to copy water mark text\r\n"));
            }
            pOEMDev->dwFontSize = FontIndexToSize(pOEMUIParam->pOEMOptItems[2].Sel);
            pOEMDev->dfRotate = (DOUBLE) pOEMUIParam->pOEMOptItems[3].Sel;
            pOEMDev->crTextColor = IndexToTextColor(pOEMUIParam->pOEMOptItems[4].Sel);
            break;

        default:
            break;
    }

    return lReturn;
}
开发者ID:340211173,项目名称:Driver,代码行数:32,代码来源:wmarkui.cpp

示例10: FakeVersion

BOOL FakeVersion(LPOSVERSIONINFOEXA pResult, VersionLieInfo* pFake)
{
    if (pResult->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA) || pResult->dwOSVersionInfoSize == sizeof(OSVERSIONINFOA) ||
        pResult->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW) || pResult->dwOSVersionInfoSize == sizeof(OSVERSIONINFOW))
    {
        pResult->dwMajorVersion = pFake->dwMajorVersion;
        pResult->dwMinorVersion = pFake->dwMinorVersion;
        pResult->dwBuildNumber = pFake->dwBuildNumber;
        pResult->dwPlatformId = pFake->dwPlatformId;
        if (pResult->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA) || pResult->dwOSVersionInfoSize == sizeof(OSVERSIONINFOA))
        {
            if (FAILED(StringCbCopyA(pResult->szCSDVersion, sizeof(pResult->szCSDVersion), pFake->szCSDVersionA)))
                return FALSE;
            if (pResult->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA) && pFake->dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)
            {
                pResult->wServicePackMajor = pFake->wServicePackMajor;
                pResult->wServicePackMinor = pFake->wServicePackMinor;
            }
        }
        else
        {
            LPOSVERSIONINFOEXW pResultW = (LPOSVERSIONINFOEXW)pResult;
            if (FAILED(StringCbCopyW(pResultW->szCSDVersion, sizeof(pResultW->szCSDVersion), pFake->szCSDVersionW)))
                return FALSE;
            if (pResultW->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW) && pFake->dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)
            {
                pResultW->wServicePackMajor = pFake->wServicePackMajor;
                pResultW->wServicePackMinor = pFake->wServicePackMinor;
            }
        }
        return TRUE;
    }
    return FALSE;
}
开发者ID:Moteesh,项目名称:reactos,代码行数:34,代码来源:versionlie.c

示例11: pCDevSettings_AllocAndCopyString

static PWSTR
pCDevSettings_AllocAndCopyString(const TCHAR *pszSrc)
{
    INT c;
    PWSTR str;

    c = _tcslen(pszSrc) + 1;
    str = (PWSTR)LocalAlloc(LMEM_FIXED,
                            c * sizeof(WCHAR));
    if (str != NULL)
    {
#ifdef UNICODE
        StringCbCopyW(str, c * sizeof(WCHAR),
               pszSrc);
#else
        MultiByteToWideChar(CP_ACP,
                            0,
                            pszSrc,
                            -1,
                            str,
                            c);
#endif
    }

    return str;
}
开发者ID:RPG-7,项目名称:reactos,代码行数:26,代码来源:devsett.c

示例12: StringCbLengthW

HRESULT CDocUIHandler::GetOptionKeyPath( 
	/* [out] */ BSTR *pchKey,
	/* [in] */ DWORD dw) 
{

	return E_NOTIMPL;
	HRESULT hr;
	WCHAR* szKey = L"ljwnb";

	//  cbLength is the length of szKey in bytes.
	size_t cbLength;
	hr = StringCbLengthW(szKey, 1280, &cbLength);
	//  TODO: Add error handling code here.

	if (pchKey)
	{
		*pchKey = (LPOLESTR)CoTaskMemAlloc(cbLength + sizeof(WCHAR));
		if (*pchKey)
			hr = StringCbCopyW(*pchKey, cbLength + sizeof(WCHAR), szKey);
	}
	else
		hr = E_INVALIDARG;

	return hr;
    
}
开发者ID:kingweiliu,项目名称:Spark,代码行数:26,代码来源:DocUIHandler.cpp

示例13: GetOrderStatusImpl

HRESULT CALLBACK GetOrderStatusImpl(
    __in const WS_OPERATION_CONTEXT* context,
    __inout unsigned int* orderID,
    __out_opt __deref __nullterminated WCHAR** status,
    __in_opt const WS_ASYNC_CONTEXT* asyncContext,
    __in_opt WS_ERROR* error)
{
    UNREFERENCED_PARAMETER(asyncContext);

    WS_HEAP* heap = NULL;
    HRESULT hr = S_OK;
    
    *orderID = *orderID;
    
    hr = WsGetOperationContextProperty(context, WS_OPERATION_CONTEXT_PROPERTY_HEAP, &heap, sizeof(heap), error);
    if (FAILED(hr))
    {
        return hr;
    }
    
    hr = WsAlloc(heap, sizeof(OrderStatusString), (void**)status, error);
    if (FAILED(hr))
    {
        return hr;
    }
    
    hr = StringCbCopyW(*status, sizeof(OrderStatusString), OrderStatusString);
    if (FAILED(hr))
    {
        return hr;
    }
    
    return S_OK;
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:34,代码来源:HttpGetService.cpp

示例14: LoadStringW

int CWnd::ShowErrorMessage(UINT nIDMsgStr,UINT nIDTitleStr,UINT uType) const
{
	if (IsUnicodeSystem())
	{
		WCHAR title[100];
		WCHAR msg[1000];
		LoadStringW(GetLanguageSpecificResourceHandle(),nIDMsgStr,msg,1000);
		if (nIDTitleStr)
			LoadStringW(GetLanguageSpecificResourceHandle(),nIDTitleStr,title,100);
		else
			StringCbCopyW(title,100*2,szwError);
		return ::MessageBoxW(m_hWnd,msg,title,uType);
	}
	else
	{
		char title[100];
		char msg[1000];
		LoadString(nIDMsgStr,msg,1000);
		if (nIDTitleStr)
			LoadString(nIDTitleStr,title,100);
		else
			StringCbCopy(title,100,szError);
		return ::MessageBox(m_hWnd,msg,title,uType);
	}
}
开发者ID:eladkarako,项目名称:locate32,代码行数:25,代码来源:WindowClasses.cpp

示例15: StringCbCopyW

DXContext::DXContext(LPDIRECT3DDEVICE9 device, wchar_t* szIniFile)
{
	m_szWindowCaption[0] = 0;
	m_hwnd = NULL;
//	m_lpD3D = NULL;
	m_lpDevice = device;
	m_hmod_d3d9 = NULL;
	m_hmod_d3dx9 = NULL;
	m_zFormat = D3DFMT_UNKNOWN;
	for (int i=0; i<MAX_DXC_ADAPTERS; i++)
		m_orig_windowed_mode_format[i] = D3DFMT_UNKNOWN;
	m_ordinal_adapter = D3DADAPTER_DEFAULT;
	m_winamp_minimized = 0;
	m_truly_exiting = 0;
	m_bpp = 0;
	m_frame_delay = 0;
	StringCbCopyW(m_szIniFile, sizeof(m_szIniFile), szIniFile);
	m_szDriver[0] = 0;
	m_szDesc[0] = 0;

	// clear the error register

	m_lastErr = S_OK;

	// clear the active flag

	m_ready=FALSE;
}
开发者ID:Phaeodaria,项目名称:Milkdrop2-XBMC,代码行数:28,代码来源:dxcontext.cpp


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