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


C++ StringCchCopyW函数代码示例

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


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

示例1: CheckPointer

//
// SetFileName
//
// Implemented for IFileSinkFilter support
//
STDMETHODIMP CDump::SetFileName(LPCOLESTR pszFileName,const AM_MEDIA_TYPE *pmt)
{
    // Is this a valid filename supplied

    CheckPointer(pszFileName,E_POINTER);
    if(wcslen(pszFileName) > MAX_PATH)
        return ERROR_FILENAME_EXCED_RANGE;

    // Take a copy of the filename

    size_t len = 1+lstrlenW(pszFileName);
    m_pFileName = new WCHAR[len];
    if (m_pFileName == 0)
        return E_OUTOFMEMORY;

    HRESULT hr = StringCchCopyW(m_pFileName, len, pszFileName);

    // Clear the global 'write error' flag that would be set
    // if we had encountered a problem writing the previous dump file.
    // (eg. running out of disk space).
    m_fWriteError = FALSE;

    // Create the file then close it

    hr = OpenFile();
    CloseFile();

    return hr;

} // SetFileName
开发者ID:zhanjx1314,项目名称:nwframework,代码行数:35,代码来源:DSFilterDump.cpp

示例2: GetFormattedErrorMessage

DWORD GetFormattedErrorMessage(__out PWSTR * pwszErrorMessage, DWORD dwMessageId, va_list* arguments)
{
    DWORD dwLength = 0;
    LPWSTR wszSystemErrorMessage = NULL;

    do
    {
        if (NULL == pwszErrorMessage)
        {
            break;
        }
        *pwszErrorMessage = NULL;

        if (NULL == g_hResourceInstance)
        {
#ifdef CORECLR
            g_hResourceInstance = LoadLibraryEx(g_MAIN_BINARY_NAME, 0, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE);
#else
            g_hResourceInstance = LoadMUILibraryW(g_MAIN_BINARY_NAME, MUI_LANGUAGE_NAME, 0);
#endif
        }

        dwLength = FormatMessageW(
            FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ALLOCATE_BUFFER,
            g_hResourceInstance,
            dwMessageId,
            0,
            (LPWSTR)&wszSystemErrorMessage,
            0,
            arguments);

        if (dwLength == 0)
        {
            break;
        }

        *pwszErrorMessage = new WCHAR[dwLength + 1];
        if (*pwszErrorMessage == NULL)
        {
            dwLength = 0;
            break;
        }

        if (FAILED(StringCchCopyW(*pwszErrorMessage, dwLength + 1, wszSystemErrorMessage)))
        {
            dwLength = 0;
            delete [] (*pwszErrorMessage);
            *pwszErrorMessage = NULL;
        }

    }while(false);

    if (NULL != wszSystemErrorMessage)
    {
        LocalFree(wszSystemErrorMessage);
    }

    return dwLength;
}
开发者ID:KevinMarquette,项目名称:Powershell,代码行数:59,代码来源:entrypoints.cpp

示例3: fwprintfEntry

int __cdecl 
fwprintfEntry( 
	FILE *stream,
	const wchar_t *format,
	...
	)
{
	PDBG_OUTPUTW Filter;
	PBTR_FILTER_RECORD Record;
	BTR_PROBE_CONTEXT Context;
	FWPRINTF Routine;
	size_t Length;
	ULONG UserLength;
	va_list argptr;
	PULONG_PTR Sp;
	ULONG Result;
	WCHAR buffer[512];
	
	BtrFltGetContext(&Context);
	Routine = Context.Destine;

	//
	// N.B. Maximum support 16 arguments
	//

	Sp = (PULONG_PTR)&format + 1;
	Result = (*Routine)(stream, format, Sp[0], Sp[1], Sp[2], Sp[3], Sp[4],
			   Sp[5], Sp[6], Sp[7], Sp[8], Sp[9], 
			   Sp[10], Sp[11], Sp[12], Sp[13]);

	BtrFltSetContext(&Context);

	__try {

		va_start(argptr, format);
		StringCchVPrintfW(buffer, 512, format, argptr);
		Length = wcslen(buffer) + 1;
		va_end(argptr);

		UserLength = FIELD_OFFSET(DBG_OUTPUTW, Text[Length]);
		Record = BtrFltAllocateRecord(UserLength, DbgUuid, _fwprintf);
		if (!Record) {
			return Result;
		}

		Filter = FILTER_RECORD_POINTER(Record, DBG_OUTPUTW);
		Filter->Length = Length;
		StringCchCopyW(Filter->Text, Length, buffer);

		BtrFltQueueRecord(Record);
	}
	__except (EXCEPTION_EXECUTE_HANDLER) {
		if (Record) {
			BtrFltFreeRecord(Record);
		}		
	}

	return Result;
}
开发者ID:Trietptm-on-Coding-Algorithms,项目名称:dprobe,代码行数:59,代码来源:dbgflt.c

示例4: OnRender

HRESULT OnRender(HDC hdc, const RECT &rcPaint)
{
    WCHAR wzText[512];

    FillRect(hdc, &rcPaint, (HBRUSH)GetStockObject(WHITE_BRUSH));

    StringCchCopyW(wzText, ARRAYSIZE(wzText), L"Source: ");

    switch(g_inputSource.deviceType)
    {
        case IMDT_UNAVAILABLE:
            StringCchCatW(wzText, ARRAYSIZE(wzText), L"Unavailable\n");
            break;

        case IMDT_KEYBOARD:
            StringCchCatW(wzText, ARRAYSIZE(wzText), L"Keyboard\n");
            break;

        case IMDT_MOUSE:
            StringCchCatW(wzText, ARRAYSIZE(wzText), L"Mouse\n");
            break;

        case IMDT_TOUCH:
            StringCchCatW(wzText, ARRAYSIZE(wzText), L"Touch\n");
            break;

        case IMDT_PEN:
            StringCchCatW(wzText, ARRAYSIZE(wzText), L"Pen\n");
            break;

    }

    StringCchCatW(wzText, ARRAYSIZE(wzText), L"Origin: ");

    switch(g_inputSource.originId)
    {
        case IMO_UNAVAILABLE:
            StringCchCatW(wzText, ARRAYSIZE(wzText), L"Unavailable\n");
            break;

        case IMO_HARDWARE:
            StringCchCatW(wzText, ARRAYSIZE(wzText), L"Hardware\n");
            break;

        case IMO_INJECTED:
            StringCchCatW(wzText, ARRAYSIZE(wzText), L"Injected\n");
            break;

        case IMO_SYSTEM:
            StringCchCatW(wzText, ARRAYSIZE(wzText), L"System\n");
            break;
    }

    DrawText(hdc, wzText, (int)wcslen(wzText), (LPRECT)&rcPaint, DT_TOP | DT_LEFT);

    return S_OK;
}
开发者ID:DMFZ,项目名称:Windows-classic-samples,代码行数:57,代码来源:InputSource.cpp

示例5: ResultFromScode

//-----------------------------------------------------------------------------------
// CImpICommandText::GetCommandText 
//
// @mfunc Echos the current command as text, including all post-processing 
//		  operations added.
//
// @rdesc HResult
//		@flag S_OK 					| Method Succeeded
//		@flag DB_S_DIALECTIGNORED	| Method succeeded, but dialect ignored
//		@flag E_INVALIDARG			| ppwszCommand was a null pointer
//		@flag E_OUTOFMEMORY			| Out of Memory
//
STDMETHODIMP CImpICommandText::GetCommandText
	(								 
	GUID		*pguidDialect,	//@parm INOUT | Guid denoting the dialect of sql
	LPOLESTR	*ppwszCommand	//@parm OUT   | Pointer for the command text
	)
{
	HRESULT		hr;

	// Check Function Arguments
	if( ppwszCommand == NULL )
	{
		hr = ResultFromScode(E_INVALIDARG);
		goto exit;
	}

	*ppwszCommand = NULL;

	// If the command has not been set, make sure the buffer
	// contains an empty stringt to return to the consumer
	if( !m_pObj->IsCommandSet() )
	{
		hr = ResultFromScode(DB_E_NOCOMMAND);
		goto exit;
	}

	assert( m_pObj->m_strCmdText );

	hr = NOERROR;

	if(  pguidDialect != NULL && 
		*pguidDialect != DBGUID_DEFAULT &&
		*pguidDialect != DBGUID_SAMPLEDIALECT )
	{
		hr = DB_S_DIALECTIGNORED;
		*pguidDialect = DBGUID_DEFAULT;
	}

	// Allocate memory for the string we're going to return to the caller
	*ppwszCommand = (LPWSTR) PROVIDER_ALLOC(
					(wcslen(m_pObj->m_strCmdText) + 1) * sizeof(WCHAR));
	
	if( !(*ppwszCommand) )
	{
		hr = ResultFromScode(E_OUTOFMEMORY);
		goto exit;
	}
	
	// Copy our saved text into the newly allocated string
	StringCchCopyW(*ppwszCommand,wcslen(m_pObj->m_strCmdText) + 1,m_pObj->m_strCmdText);

exit:

	if( FAILED(hr) && pguidDialect )
		memset(pguidDialect, 0, sizeof(GUID));

	return hr;
}
开发者ID:AbdoSalem95,项目名称:WindowsSDK7-Samples,代码行数:69,代码来源:command.cpp

示例6: AllocateTraceProperties

PEVENT_TRACE_PROPERTIES
AllocateTraceProperties (
    _In_opt_ PWSTR LoggerName,
    _In_opt_ PWSTR LogFileName
    )
{
    PEVENT_TRACE_PROPERTIES TraceProperties = NULL;
    ULONG BufferSize;

    BufferSize = sizeof(EVENT_TRACE_PROPERTIES) + 
        (MAXIMUM_SESSION_NAME + MAX_PATH) * sizeof(WCHAR);

    TraceProperties = (PEVENT_TRACE_PROPERTIES)malloc(BufferSize);  
    if (TraceProperties == NULL) {
        wprintf(L"Unable to allocate %d bytes for properties structure.\n", BufferSize);
        goto Exit;
    }

    //
    // Set the session properties.
    //

    ZeroMemory(TraceProperties, BufferSize);
    TraceProperties->Wnode.BufferSize = BufferSize;
    TraceProperties->Wnode.Flags = WNODE_FLAG_TRACED_GUID;
    TraceProperties->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
    TraceProperties->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES) + 
        (MAXIMUM_SESSION_NAME * sizeof(WCHAR)); 

    if (LoggerName != NULL) {
        StringCchCopyW((LPWSTR)((PCHAR)TraceProperties + TraceProperties->LoggerNameOffset), 
                      MAXIMUM_SESSION_NAME,
                      LoggerName);
    }

    if (LogFileName != NULL) {
        StringCchCopyW((LPWSTR)((PCHAR)TraceProperties + TraceProperties->LogFileNameOffset), 
                      MAX_PATH, 
                      LogFileName);
    }

Exit:
    return TraceProperties;
}
开发者ID:CM44,项目名称:Windows-driver-samples,代码行数:44,代码来源:SystemTraceControl.cpp

示例7: CpiReadPropertyList

HRESULT CpiReadPropertyList(
	LPWSTR* ppwzData,
	CPI_PROPERTY** ppPropList
	)
{
	HRESULT hr = S_OK;

	CPI_PROPERTY* pItm = NULL;
	LPWSTR pwzName = NULL;

	// clear list if it already contains items
	if (*ppPropList)
		CpiFreePropertyList(*ppPropList);
	*ppPropList = NULL;

	// read property count
	int iPropCnt = 0;
	hr = WcaReadIntegerFromCaData(ppwzData, &iPropCnt);
	ExitOnFailure(hr, "Failed to read property count");

	for (int i = 0; i < iPropCnt; i++)
	{
		// allocate new element
		pItm = (CPI_PROPERTY*)::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CPI_PROPERTY));
		if (!pItm)
			ExitFunction1(hr = E_OUTOFMEMORY);

		// Name
		hr = WcaReadStringFromCaData(ppwzData, &pwzName);
		ExitOnFailure(hr, "Failed to read name");
		StringCchCopyW(pItm->wzName, countof(pItm->wzName), pwzName);

		// Value
		hr = WcaReadStringFromCaData(ppwzData, &pItm->pwzValue);
		ExitOnFailure(hr, "Failed to read property value");

		// add to list
		if (*ppPropList)
			pItm->pNext = *ppPropList;
		*ppPropList = pItm;
		pItm = NULL;
	}

	hr = S_OK;

LExit:
	// clean up
	ReleaseStr(pwzName);

	if (pItm)
		CpiFreePropertyList(pItm);

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

示例8: lstrdup

wchar_t* lstrdup(const wchar_t* asText)
{
    int nLen = asText ? lstrlenW(asText) : 0;
    wchar_t* psz = (wchar_t*)malloc((nLen+1) * sizeof(*psz));

    if (nLen)
        StringCchCopyW(psz, nLen+1, asText);
    else
        psz[0] = 0;

    return psz;
}
开发者ID:john-peterson,项目名称:conemu,代码行数:12,代码来源:Memory.cpp

示例9: SetWatsonType

//============================================================================
// Set the process-wide behavior of Watson. Default is to prompt.
//============================================================================
void SetWatsonType(WATSON_TYPE WatsonType, LCID WatsonLcid, _In_opt_z_ WCHAR *wszAdditionalFiles)
{
    g_WatsonType = WatsonType;
    g_WatsonLcid = WatsonLcid;

    if (wszAdditionalFiles)
    {
        g_wszAdditionalFiles[0] = '\0';
        g_fAdditionalFiles = true;
        StringCchCopyW(g_wszAdditionalFiles, DIM(g_wszAdditionalFiles), wszAdditionalFiles);
    }
}
开发者ID:JianwenSun,项目名称:cc,代码行数:15,代码来源:exceptions.cpp

示例10: wcslen

/*
 * Allocate (duplicate) a wide char string.
 */
PWSTR MEMHEAP::AllocStr(PCWSTR str)
{
    if (str == NULL)
        return NULL;

    size_t str_len = wcslen(str) + 1;
    PWSTR strNew = (PWSTR) Alloc(str_len * sizeof(WCHAR));
    HRESULT hr;
    hr = StringCchCopyW(strNew, str_len, str);
    ASSERT (SUCCEEDED (hr));
    return strNew;
}
开发者ID:Anupam-,项目名称:shared-source-cli-2.0,代码行数:15,代码来源:alloc.cpp

示例11: GetEventCategory

BOOL
GetEventCategory(IN LPCWSTR KeyName,
                 IN LPCWSTR SourceName,
                 IN EVENTLOGRECORD *pevlr,
                 OUT PWCHAR CategoryName)
{
    HANDLE hLibrary = NULL;
    WCHAR szMessageDLL[MAX_PATH];
    LPVOID lpMsgBuf = NULL;

    if (GetEventMessageFileDLL (KeyName, SourceName, EVENT_CATEGORY_MESSAGE_FILE , szMessageDLL))
    {
        hLibrary = LoadLibraryExW(szMessageDLL,
                                 NULL,
                                 DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
        if (hLibrary != NULL)
        {
            /* Retrieve the message string. */
            if (FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ARGUMENT_ARRAY,
                              hLibrary,
                              pevlr->EventCategory,
                              MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                              (LPWSTR)&lpMsgBuf,
                              EVENT_MESSAGE_FILE_BUFFER,
                              NULL) != 0)
            {
                /* Trim the string */
                TrimNulls(lpMsgBuf);

                /* Copy the category name */
                StringCchCopyW(CategoryName, MAX_PATH, lpMsgBuf);
            }
            else
            {
                LoadStringW(hInst, IDS_NONE, CategoryName, MAX_PATH);
            }

            if (hLibrary != NULL)
                FreeLibrary(hLibrary);

            /* Free the buffer allocated by FormatMessage */
            if (lpMsgBuf)
                LocalFree(lpMsgBuf);

            return TRUE;
        }
    }

    LoadStringW(hInst, IDS_NONE, CategoryName, MAX_PATH);

    return FALSE;
}
开发者ID:Strongc,项目名称:reactos,代码行数:52,代码来源:eventvwr.c

示例12: StringCchCopyW

void
HippoIcon::updateTip(const WCHAR *tip)
{
    NOTIFYICONDATA notifyIconData = { 0 };
    notifyIconData.uID = 0;
    notifyIconData.hWnd = window_;
    notifyIconData.uFlags = NIF_TIP;
    StringCchCopyW(notifyIconData.szTip, 
                   sizeof(notifyIconData.szTip) / sizeof(notifyIconData.szTip[0]),
                   tip);
    notifyIconData.szTip;
    Shell_NotifyIcon(NIM_MODIFY, &notifyIconData);
}
开发者ID:manoj-makkuboy,项目名称:magnetism,代码行数:13,代码来源:HippoIcon.cpp

示例13: switch

IFACEMETHODIMP OCContextMenu::GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax)
{
	HRESULT hr = E_INVALIDARG;

	if (idCmd == IDM_SHARE)
	{
		switch (uFlags)
		{
		case GCS_HELPTEXTW:
			hr = StringCchCopyW(reinterpret_cast<PWSTR>(pszName), cchMax, L"Shares file or directory with ownCloud");
			break;

		case GCS_VERBW:
			// GCS_VERBW is an optional feature that enables a caller
			// to discover the canonical name for the verb that is passed in
			// through idCommand.
			hr = StringCchCopyW(reinterpret_cast<PWSTR>(pszName), cchMax, L"ownCloudShare");
			break;
		}
	}
	return hr;
}
开发者ID:24killen,项目名称:client,代码行数:22,代码来源:OCContextMenu.cpp

示例14: lstrdup

wchar_t* lstrdup(const wchar_t* asText, size_t cchExtraSizeAdd /* = 0 */)
{
	size_t nLen = asText ? lstrlenW(asText) : 0;
	wchar_t* psz = (wchar_t*)malloc((nLen+1+cchExtraSizeAdd) * sizeof(*psz));

	if (nLen)
		StringCchCopyW(psz, nLen+1, asText);

	// Ensure AsciiZ
	psz[nLen] = 0;

	return psz;
}
开发者ID:rheostat2718,项目名称:conemu-maximus5,代码行数:13,代码来源:Memory.cpp

示例15: GetImmFileName

HRESULT WINAPI GetImmFileName(PWSTR lpBuffer, UINT uSize)
{
  UINT length;
  STRSAFE_LPWSTR Safe = lpBuffer;

  length = GetSystemDirectoryW(lpBuffer, uSize);
  if ( length && length < uSize )
  {
    StringCchCatW(Safe, uSize, L"\\");
    return StringCchCatW(Safe, uSize, L"imm32.dll");
  }
  return StringCchCopyW(Safe, uSize, L"imm32.dll");
}  
开发者ID:Moteesh,项目名称:reactos,代码行数:13,代码来源:imm.c


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