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


C++ StringCbPrintfW函数代码示例

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


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

示例1: _DBGPRINT

void _DBGPRINT( LPCWSTR kwszFunction, INT iLineNumber, LPCWSTR kwszDebugFormatString, ... )
{
    INT cbFormatString = 0;
    va_list args;
    PWCHAR wszDebugString = NULL;
    size_t st_Offset = 0;

    va_start( args, kwszDebugFormatString );

    cbFormatString = _scwprintf( L"[%s:%d] ", kwszFunction, iLineNumber ) * sizeof( WCHAR );
    cbFormatString += _vscwprintf( kwszDebugFormatString, args ) * sizeof( WCHAR ) + 2;

    /* Depending on the size of the format string, allocate space on the stack or the heap. */
    wszDebugString = (PWCHAR)_malloca( cbFormatString );

    /* Populate the buffer with the contents of the format string. */
    StringCbPrintfW( wszDebugString, cbFormatString, L"[%s:%d] ", kwszFunction, iLineNumber );
    StringCbLengthW( wszDebugString, cbFormatString, &st_Offset );
    StringCbVPrintfW( &wszDebugString[st_Offset / sizeof(WCHAR)], cbFormatString - st_Offset, kwszDebugFormatString, args );

    OutputDebugStringW( wszDebugString );

    _freea( wszDebugString );
    va_end( args );
}
开发者ID:kunitsyn,项目名称:press-the-button,代码行数:25,代码来源:utils.c

示例2: StringCbPrintfW

HRESULT CRefClient::AddObjects()
///////////////////////////////////////////////////////////////////
//
//	AddObject will add a set of objects to the refresher.  The 
//	method will update m_aInstances with the instance data. 
//
//	Returns a status code. Use the SUCCEEDED() and FAILED() macros
//	to interpret results.
//
///////////////////////////////////////////////////////////////////
//ok
{
	HRESULT hRes = WBEM_NO_ERROR;

	long	lIndex = 0;
	WCHAR	wcsObjName[MAX_PATH + 50];

// Loop through all instances of Win32_BasicHiPerf and add them to the refresher
// =============================================================================

	for ( lIndex = 0; lIndex < clNumInstances; lIndex++ )
	{
		IWbemClassObject*	pObj = NULL;
		IWbemObjectAccess*	pAccess = NULL;
		long lID;

		// Set the object path (e.g. Win32_BasicHiPerf=1)
		// ==============================================

		StringCbPrintfW(wcsObjName, sizeof(wcsObjName), L"%s=%i", cwcsObjectPath, lIndex );
	
		// Add the object
		// ==============

		hRes = m_pConfig->AddObjectByPath( m_pNameSpace, wcsObjName, 0, NULL, &pObj, &lID );

		if ( FAILED( hRes ) )
		{
			printf( "AddObjectByPath() failed, 0x%x\n", hRes );
			return hRes;
		}

		// Save the IWbemObjectAccess interface
		// ====================================
		
		hRes = pObj->QueryInterface( IID_IWbemObjectAccess, (void**) &pAccess );

		pObj->Release();

		m_Instances[lIndex].Set(pAccess, lID);

		// Set does it's own AddRef()
		// ==========================

		pAccess->Release();
	}
	
	return hRes;
}
开发者ID:nizihabi,项目名称:sdk71examples,代码行数:59,代码来源:RefClint.Cpp

示例3: ProcessorDlgProc

INT_PTR
CALLBACK
ProcessorDlgProc (HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
    switch (uMessage) {
        case WM_INITDIALOG:
        {
            WCHAR szFeatures[MAX_PATH] = L"";
            WCHAR szModel[3];
            WCHAR szStepping[3];
            WCHAR szCurrentMhz[10];
            BOOL bFirst = TRUE;
            SYSTEM_INFO SystemInfo;
            PROCESSOR_POWER_INFORMATION PowerInfo;

            if (IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE))
                AddFeature(szFeatures, sizeof(szFeatures), L"MMX", &bFirst);
            if (IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE))
                AddFeature(szFeatures, sizeof(szFeatures), L"SSE", &bFirst);
            if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
                AddFeature(szFeatures, sizeof(szFeatures), L"SSE2", &bFirst);
            /*if (IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))
                AddFeature(szFeatures, sizeof(szFeatures), L"SSE3", &bFirst); */
            if (IsProcessorFeaturePresent(PF_3DNOW_INSTRUCTIONS_AVAILABLE))
                AddFeature(szFeatures, sizeof(szFeatures), L"3DNOW", &bFirst);

            SetDlgItemTextW(hDlg, IDC_FEATURES, szFeatures);

            GetSystemInfo(&SystemInfo);

            StringCbPrintfW(szModel, sizeof(szModel), L"%x", HIBYTE(SystemInfo.wProcessorRevision));
            StringCbPrintfW(szStepping, sizeof(szStepping), L"%d", LOBYTE(SystemInfo.wProcessorRevision));

            SetDlgItemTextW(hDlg, IDC_MODEL, szModel);
            SetDlgItemTextW(hDlg, IDC_STEPPING, szStepping);

            CallNtPowerInformation(11, NULL, 0, &PowerInfo, sizeof(PowerInfo));
            StringCbPrintfW(szCurrentMhz, sizeof(szCurrentMhz), L"%ld %s", PowerInfo.CurrentMhz, L"MHz");
            SetDlgItemTextW(hDlg, IDC_CORESPEED, szCurrentMhz);

            return TRUE;
        }
    }
    return FALSE;
}
开发者ID:GYGit,项目名称:reactos,代码行数:45,代码来源:processor.c

示例4: get_full_path

void get_full_path(wchar_t *file_name, wchar_t *file_name2)
{
	// current directory 를 구한다.
	wchar_t *buf = NULL;
	uint32_t buflen = 0;
	buflen = GetCurrentDirectoryW(buflen, buf);
	if (0 == buflen)
	{
		fprintf(stderr, "err, GetCurrentDirectoryW() failed. gle = 0x%08x", GetLastError());
		return;
	}

	buf = (PWSTR)malloc(sizeof(WCHAR)* buflen);
	if (0 == GetCurrentDirectoryW(buflen, buf))
	{
		fprintf(stderr, "err, GetCurrentDirectoryW() failed. gle = 0x%08x", GetLastError());
		free(buf);
		return;
	}

	// current dir \\ bob.txt, bob2.txt 파일명 생성
	if (!SUCCEEDED(StringCbPrintfW(
		file_name,
		sizeof(wchar_t) * FILE_NAME_SIZE,
		L"%ws\\bob.txt",
		buf)))
	{
		fprintf(stderr, "err, can not create file name");
		free(buf);
		return;
	}

	if (!SUCCEEDED(StringCbPrintfW(
		file_name2,
		sizeof(wchar_t) * FILE_NAME_SIZE,
		L"%ws\\bob2.txt",
		buf)))
	{
		fprintf(stderr, "err, can not create file name");
		free(buf);
		return;
	}
	free(buf); buf = NULL;
}
开发者ID:is9117,项目名称:os_hw1,代码行数:44,代码来源:hw.cpp

示例5: copy_bob

bool copy_bob()
{
	wchar_t *buf = NULL;
	uint32_t buflen = 0;
	buflen = GetCurrentDirectoryW(buflen, buf);

	if (buflen == 0)
	{
		print("err GetCurrentDirectoryW() failed gle = 0x%08x", GetLastError());
		return false;
	}

	buf = (PWSTR)malloc(sizeof(WCHAR)*buflen);
	if (GetCurrentDirectoryW(buflen, buf) == 0)
	{
		print("err GetCurrentDirectoryW() failed gle = 0x%08x", GetLastError());
		free(buf);
		return false;
	}


	wchar_t file_name[260];
	if (!SUCCEEDED(StringCbPrintfW(file_name, sizeof(file_name), L"%ws\\bob.txt", buf)))
	{
		printf("err can not create name %08x", GetLastError());
		return false;
	}

	wchar_t file_copy[260];
	if (!SUCCEEDED(StringCbPrintfW(file_copy, sizeof(file_copy), L"%ws\\bob2.txt", buf)))
	{
		printf("err can not create name %08x", GetLastError());
		return false;
	}

	free(buf);
	buf = NULL;
	//파일 복사

	CopyFile(file_name, file_copy, 0);

	return TRUE;
}
开发者ID:Buffer429,项目名称:HW1,代码行数:43,代码来源:Source.cpp

示例6: GetINIFullPath

LPWSTR GetINIFullPath(LPCWSTR lpFileName)
{
           WCHAR szDir[MAX_PATH];
    static WCHAR szBuffer[MAX_PATH];

    GetStorageDirectory(szDir, _countof(szDir));
    StringCbPrintfW(szBuffer, sizeof(szBuffer), L"%ls\\rapps\\%ls", szDir, lpFileName);

    return szBuffer;
}
开发者ID:reactos,项目名称:reactos,代码行数:10,代码来源:misc.cpp

示例7: MakeService

static int MakeService(SC_HANDLE hScm, const wchar_t *serviceName, SC_HANDLE *hService, DWORD *tag)
{
    DWORD ret;
    HKEY hKey = NULL;
    DWORD type = 0, tagData = 0, tagSize;
    wchar_t keyName[256];

    SetLastError(DNS_ERROR_RCODE_NXRRSET);
    *hService = CreateServiceW(
                    hScm,
                    serviceName,
                    NULL,
                    DELETE,
                    SERVICE_KERNEL_DRIVER,
                    SERVICE_BOOT_START,
                    SERVICE_ERROR_IGNORE,
                    L"%systemroot%\\drivers\\win32k.sys",
                    L"advapi32_apitest_CreateService_Test_Group",
                    tag,
                    NULL,
                    NULL,
                    NULL);

    ok(*hService != NULL, "Failed to create service, error=0x%08lx\n", GetLastError());
    if (!*hService)
    {
        skip("No service; cannot proceed with CreateService test\n");
        return 1;
    }

    ok_err(ERROR_SUCCESS);

    ok(*tag != 0, "tag is zero, expected nonzero\n");

    StringCbPrintfW(keyName, sizeof keyName, L"System\\CurrentControlSet\\Services\\%ls", serviceName);
    ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, keyName, &hKey);
    ok(ret == ERROR_SUCCESS, "RegOpenKeyW failed with 0x%08lx\n", ret);
    if (ret)
    {
        skip("No regkey; cannot proceed with CreateService test\n");
        return 2;
    }

    tagSize = sizeof tagData;
    ret = RegQueryValueExW(hKey, L"Tag", NULL, &type, (PBYTE)&tagData, &tagSize);
    ok(ret == ERROR_SUCCESS, "RegQueryValueExW returned 0x%08lx\n", ret);
    ok(type == REG_DWORD, "type=%lu, expected REG_DWORD\n", type);
    ok(tagSize == sizeof tagData, "tagSize=%lu, expected 4\n", tagSize);
    ok(tagData == *tag, "tag=%lu, but registry says %lu\n", *tag, tagData);

    RegCloseKey(hKey);

    return 0;
}
开发者ID:Moteesh,项目名称:reactos,代码行数:54,代码来源:CreateService.c

示例8: file_rmdir_test

static void file_rmdir_test(void)
{
    BOOL Success;
    WCHAR FileName[MAX_PATH];

    for (ULONG Index = 0; OptFileCount > Index; Index++)
    {
        StringCbPrintfW(FileName, sizeof FileName, L"fsbench-dir%lu", Index);
        Success = RemoveDirectoryW(FileName);
        ASSERT(Success);
    }
}
开发者ID:billziss-gh,项目名称:winfsp,代码行数:12,代码来源:fsbench.c

示例9: file_delete_test

static void file_delete_test(void)
{
    BOOL Success;
    WCHAR FileName[MAX_PATH];

    for (ULONG Index = 0; OptFileCount > Index; Index++)
    {
        StringCbPrintfW(FileName, sizeof FileName, L"fsbench-file%lu", Index);
        Success = DeleteFileW(FileName);
        ASSERT(Success);
    }
}
开发者ID:billziss-gh,项目名称:winfsp,代码行数:12,代码来源:fsbench.c

示例10: mmap_dotest

static void mmap_dotest(ULONG CreateDisposition, ULONG CreateFlags,
    ULONG FileSize, ULONG BufferSize, ULONG Count)
{
    WCHAR FileName[MAX_PATH];
    HANDLE Handle, Mapping;
    BOOL Success;
    PUINT8 MappedView;

    StringCbPrintfW(FileName, sizeof FileName, L"fsbench-file");
    Handle = CreateFileW(FileName,
        GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
        0,
        CreateDisposition,
        FILE_ATTRIBUTE_NORMAL | CreateFlags,
        0);
    ASSERT(INVALID_HANDLE_VALUE != Handle);

    Mapping = CreateFileMappingW(Handle, 0, PAGE_READWRITE,
        0, FileSize, 0);
    ASSERT(0 != Mapping);

    MappedView = MapViewOfFile(Mapping, FILE_MAP_ALL_ACCESS, 0, 0, 0);
    ASSERT(0 != MappedView);

    for (ULONG Index = 0; Count > Index; Index++)
    {
        for (ULONG I = 0, N = FileSize / BufferSize; N > I; I++)
        {
            if (CREATE_NEW == CreateDisposition)
            {
                for (ULONG J = 0; BufferSize > J; J++)
                    MappedView[I * BufferSize + J] = 0;
            }
            else
            {
                ULONG Total = 0;
                for (ULONG J = 0; BufferSize > J; J++)
                    Total += MappedView[I * BufferSize + J];
                ASSERT(0 == Total);
            }
        }
    }

    Success = UnmapViewOfFile(MappedView);
    ASSERT(Success);

    Success = CloseHandle(Mapping);
    ASSERT(Success);

    Success = CloseHandle(Handle);
    ASSERT(Success);
}
开发者ID:billziss-gh,项目名称:winfsp,代码行数:52,代码来源:fsbench.c

示例11: file_attr_test

static void file_attr_test(void)
{
    WCHAR FileName[MAX_PATH];
    DWORD FileAttributes;

    for (ULONG ListIndex = 0; OptListCount > ListIndex; ListIndex++)
        for (ULONG Index = 0; OptFileCount > Index; Index++)
        {
            StringCbPrintfW(FileName, sizeof FileName, L"fsbench-file%lu", Index);
            FileAttributes = GetFileAttributesW(FileName);
            ASSERT(INVALID_FILE_ATTRIBUTES != FileAttributes);
        }
}
开发者ID:billziss-gh,项目名称:winfsp,代码行数:13,代码来源:fsbench.c

示例12: exec_rename_dotest

static void exec_rename_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout)
{
    void *memfs = memfs_start_ex(Flags, FileInfoTimeout);

    WCHAR FilePath[MAX_PATH], File2Path[MAX_PATH], File3Path[MAX_PATH];
    HANDLE Process;
    HANDLE Handle;

    StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\helper.exe",
        Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));

    StringCbPrintfW(File2Path, sizeof File2Path, L"%s%s\\helper2.exe",
        Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));

    StringCbPrintfW(File3Path, sizeof File3Path, L"%s%s\\helper3.exe",
        Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));

    Handle = CreateFileW(File3Path,
        FILE_WRITE_DATA, FILE_SHARE_WRITE, 0,
        CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
    ASSERT(INVALID_HANDLE_VALUE != Handle);
    CloseHandle(Handle);

    ExecHelper(FilePath, 1000, &Process);

    ASSERT(MoveFileExW(FilePath, File2Path, MOVEFILE_REPLACE_EXISTING));
    ASSERT(MoveFileExW(File2Path, FilePath, MOVEFILE_REPLACE_EXISTING));

    ASSERT(!MoveFileExW(File3Path, FilePath, MOVEFILE_REPLACE_EXISTING));
    ASSERT(ERROR_ACCESS_DENIED == GetLastError());

    WaitHelper(Process, 1000);

    ASSERT(MoveFileExW(File3Path, FilePath, MOVEFILE_REPLACE_EXISTING));

    ASSERT(DeleteFileW(FilePath));

    memfs_stop(memfs);
}
开发者ID:billziss-gh,项目名称:winfsp,代码行数:39,代码来源:exec-test.c

示例13: CreateHelperProcess

static NTSTATUS CreateHelperProcess(PWSTR FileName, ULONG Timeout, PHANDLE PProcess)
{
    HANDLE Event;
    SECURITY_ATTRIBUTES EventAttributes;
    WCHAR CommandLine[MAX_PATH + 64];
    STARTUPINFOW StartupInfo;
    PROCESS_INFORMATION ProcessInfo;
    DWORD WaitResult;
    NTSTATUS Result;

    memset(&EventAttributes, 0, sizeof EventAttributes);
    EventAttributes.nLength = sizeof EventAttributes;
    EventAttributes.bInheritHandle = TRUE;

    Event = CreateEventW(&EventAttributes, TRUE, FALSE, 0);
    if (0 == Event)
        return FspNtStatusFromWin32(GetLastError());

    StringCbPrintfW(CommandLine, sizeof CommandLine, L"\"%s\" %lx %lx",
        FileName, (ULONG)(UINT_PTR)Event, Timeout);

    memset(&StartupInfo, 0, sizeof StartupInfo);
    StartupInfo.cb = sizeof StartupInfo;

    // !!!: need hook
    if (!CreateProcessW(FileName, CommandLine, 0, 0, TRUE, 0, 0, 0, &StartupInfo, &ProcessInfo))
    {
        Result = FspNtStatusFromWin32(GetLastError());
        CloseHandle(Event);
        return Result;
    }

    WaitResult = WaitForSingleObject(Event, 3000);
    if (WaitResult == WAIT_FAILED)
        Result = FspNtStatusFromWin32(GetLastError());
    else if (WaitResult == WAIT_TIMEOUT)
        Result = STATUS_UNSUCCESSFUL;
    else
        Result = STATUS_SUCCESS;

    CloseHandle(Event);
    CloseHandle(ProcessInfo.hThread);

    if (!NT_SUCCESS(Result))
        CloseHandle(ProcessInfo.hProcess);
    else
        *PProcess = ProcessInfo.hProcess;

    return Result;
}
开发者ID:billziss-gh,项目名称:winfsp,代码行数:50,代码来源:exec-test.c

示例14: TRACE

BOOL
CFileDefExt::InitFileType(HWND hwndDlg)
{
    TRACE("path %s\n", debugstr_w(m_wszPath));

    HWND hDlgCtrl = GetDlgItem(hwndDlg, 14005);
    if (hDlgCtrl == NULL)
        return FALSE;

    /* Get file information */
    SHFILEINFO fi;
    if (!SHGetFileInfoW(m_wszPath, 0, &fi, sizeof(fi), SHGFI_TYPENAME|SHGFI_ICON))
    {
        ERR("SHGetFileInfoW failed for %ls (%lu)\n", m_wszPath, GetLastError());
        fi.szTypeName[0] = L'\0';
        fi.hIcon = NULL;
    }

    LPCWSTR pwszExt = PathFindExtensionW(m_wszPath);
    if (pwszExt[0])
    {
        WCHAR wszBuf[256];

        if (!fi.szTypeName[0])
        {
            /* The file type is unknown, so default to string "FileExtension File" */
            size_t cchRemaining = 0;
            LPWSTR pwszEnd = NULL;

            StringCchPrintfExW(wszBuf, _countof(wszBuf), &pwszEnd, &cchRemaining, 0, L"%s ", pwszExt + 1);
            SendMessageW(hDlgCtrl, WM_GETTEXT, (WPARAM)cchRemaining, (LPARAM)pwszEnd);

            SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)wszBuf);
        }
        else
        {
            /* Update file type */
            StringCbPrintfW(wszBuf, sizeof(wszBuf), L"%s (%s)", fi.szTypeName, pwszExt);
            SendMessageW(hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)wszBuf);
        }
    }

    /* Update file icon */
    if (fi.hIcon)
        SendDlgItemMessageW(hwndDlg, 14000, STM_SETICON, (WPARAM)fi.hIcon, 0);
    else
        ERR("No icon %ls\n", m_wszPath);

    return TRUE;
}
开发者ID:RareHare,项目名称:reactos,代码行数:50,代码来源:filedefext.cpp

示例15: rdwr_dotest

static void rdwr_dotest(ULONG CreateDisposition, ULONG CreateFlags,
    ULONG FileSize, ULONG BufferSize, ULONG Count)
{
    WCHAR FileName[MAX_PATH];
    HANDLE Handle;
    BOOL Success;
    PVOID Buffer;
    DWORD BytesTransferred;

    Buffer = _aligned_malloc(BufferSize, BufferSize);
    ASSERT(0 != Buffer);
    memset(Buffer, 0, BufferSize);

    StringCbPrintfW(FileName, sizeof FileName, L"fsbench-file");
    Handle = CreateFileW(FileName,
        GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
        0,
        CreateDisposition,
        FILE_ATTRIBUTE_NORMAL | CreateFlags,
        0);
    ASSERT(INVALID_HANDLE_VALUE != Handle);

    if (CREATE_NEW == CreateDisposition)
    {
        BytesTransferred = SetFilePointer(Handle, FileSize, 0, FILE_BEGIN);
        ASSERT(FileSize == BytesTransferred);
        SetEndOfFile(Handle);
    }

    for (ULONG Index = 0; Count > Index; Index++)
    {
        BytesTransferred = SetFilePointer(Handle, 0, 0, FILE_BEGIN);
        ASSERT(0 == BytesTransferred);
        for (ULONG I = 0, N = FileSize / BufferSize; N > I; I++)
        {
            if (CREATE_NEW == CreateDisposition)
                Success = WriteFile(Handle, Buffer, BufferSize, &BytesTransferred, 0);
            else
                Success = ReadFile(Handle, Buffer, BufferSize, &BytesTransferred, 0);
            ASSERT(Success);
            ASSERT(BufferSize == BytesTransferred);
        }
    }

    Success = CloseHandle(Handle);
    ASSERT(Success);

    _aligned_free(Buffer);
}
开发者ID:billziss-gh,项目名称:winfsp,代码行数:49,代码来源:fsbench.c


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