您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ swprintf_s函数代码示例

51自学网 2021-06-03 08:36:00
  C++
这篇教程C++ swprintf_s函数代码示例写得很实用,希望能帮到您。

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

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

示例1: ListView_GetColumn

void CProcesses::OnLvnGetdispinfoProcessList(NMHDR *pNMHDR, LRESULT *pResult){    NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);    LVCOLUMN  col;    col.mask = LVCF_SUBITEM;    /*Get the colum Info*/    ListView_GetColumn(hProcPageListCtrl,pDispInfo->item.iSubItem,&col);    if(columns[col.iSubItem].isShow)    {        PERFDATA *pPerfData = (PERFDATA *)pDispInfo->item.lParam;        /*Set the Column Data*/        switch(columns[col.iSubItem].nId)        {        case COLUMN_IMAGENAME:            break;        case COLUMN_PID:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%d"),pPerfData->ProcessId);            break;        case COLUMN_USERNAME:            pDispInfo->item.pszText = pPerfData->UserName;            break;        case COLUMN_SESSIONID:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%d"),pPerfData->SessionId);            break;        case COLUMN_CPUUSAGE:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%02d"),pPerfData->CPUUsage);            break;        case COLUMN_CPUTIME:            DWORD dwHours;            DWORD dwMinutes;            DWORD dwSeconds;            GetHMSFromLargeInt(pPerfData->CPUTime, &dwHours, &dwMinutes, &dwSeconds);            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%02d:%02d:%02d"),dwHours,dwMinutes,dwSeconds);            break;        case COLUMN_MEMORYUSAGE:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%d"),pPerfData->WorkingSetSizeBytes / 1024);            SeparateNumber(pDispInfo->item.pszText,pDispInfo->item.cchTextMax);            wcscat(pDispInfo->item.pszText,_T(" K"));            break;        case COLUMN_PEAKMEMORYUSAGE:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%d")                       ,pPerfData->PeakWorkingSetSizeBytes / 1024);            SeparateNumber(pDispInfo->item.pszText,pDispInfo->item.cchTextMax);            wcscat(pDispInfo->item.pszText,_T(" K"));            break;        case COLUMN_MEMORYUSAGEDELTA:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%d"),pPerfData->WorkingSetSizeDelta / 1024);            SeparateNumber(pDispInfo->item.pszText,pDispInfo->item.cchTextMax);            wcscat(pDispInfo->item.pszText,_T(" K"));            break;        case COLUMN_PAGEFAULTS:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%d"),pPerfData->PageFaultCount);            SeparateNumber(pDispInfo->item.pszText,pDispInfo->item.cchTextMax);            break;        case COLUMN_PAGEFAULTSDELTA:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%d"),pPerfData->PageFaultCountDelta);            SeparateNumber(pDispInfo->item.pszText,pDispInfo->item.cchTextMax);            break;        case COLUMN_VIRTUALMEMORYSIZE:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%d"),pPerfData->VirtualMemorySizeBytes / 1024);            SeparateNumber(pDispInfo->item.pszText,pDispInfo->item.cchTextMax);            wcscat(pDispInfo->item.pszText,_T(" K"));            break;        case COLUMN_PAGEDPOOL:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%d"),pPerfData->PagedPoolUsagePages / 1024);            SeparateNumber(pDispInfo->item.pszText,pDispInfo->item.cchTextMax);            wcscat(pDispInfo->item.pszText,_T(" K"));            break;        case COLUMN_NONPAGEDPOOL:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%d"),pPerfData->NonPagedPoolUsagePages / 1024);            SeparateNumber(pDispInfo->item.pszText,pDispInfo->item.cchTextMax);            wcscat(pDispInfo->item.pszText,_T(" K"));            break;        case COLUMN_BASEPRIORITY:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%d"),pPerfData->BasePriority);            break;        case COLUMN_HANDLECOUNT:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%d"),pPerfData->HandleCount);            SeparateNumber(pDispInfo->item.pszText,pDispInfo->item.cchTextMax);            break;        case COLUMN_THREADCOUNT:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%d"),pPerfData->ThreadCount);            SeparateNumber(pDispInfo->item.pszText,pDispInfo->item.cchTextMax);            break;        case COLUMN_USEROBJECTS:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%d"),pPerfData->USERObjectCount);            SeparateNumber(pDispInfo->item.pszText,pDispInfo->item.cchTextMax);            break;        case COLUMN_GDIOBJECTS:            swprintf_s(pDispInfo->item.pszText,pDispInfo->item.cchTextMax,_T("%d"),pPerfData->GDIObjectCount);            SeparateNumber(pDispInfo->item.pszText,pDispInfo->item.cchTextMax);            break;        case COLUMN_IOREADS:            _ui64tow(pPerfData->IOCounters.ReadOperationCount,pDispInfo->item.pszText,10);            SeparateNumber(pDispInfo->item.pszText,pDispInfo->item.cchTextMax);            break;        case COLUMN_IOWRITES:            _ui64tow(pPerfData->IOCounters.WriteOperationCount,pDispInfo->item.pszText,10);//.........这里部分代码省略.........
开发者ID:wakaoyun,项目名称:dengqibin,代码行数:101,


示例2: WszGetModuleHandle

//-----------------------------------------------------------------------------// Based on the pid, write a unique name for the IPCBlockTable on Vista and Higher//-----------------------------------------------------------------------------HRESULT IPCShared::GenerateBlockTableName(DWORD pid, SString & sName, HANDLE & pBoundaryDesc, HANDLE & pPrivateNamespace, PSID* pSID, BOOL bCreate){    WRAPPER_NO_CONTRACT;    HRESULT hr = E_FAIL;#define SIZE 100    const WCHAR * szFormat = CorSxSPublicIPCBlock;    static HMODULE hKernel32 = NULL;    if(hKernel32 == NULL)        hKernel32 = WszGetModuleHandle(L"kernel32.dll");    if(hKernel32 == NULL)    {        hr = HRESULT_FROM_GetLastError();        return hr;    }    //We are using static function pointers so that we dont call GetProcAddress every time    //We know that the Writer will call this function only once and the reader (perfmon) is a single    //threaded App. Therefore its safe to assign static local variables in this case.     typedef WINBASEAPI BOOL (WINAPI ADD_SID_TO_BOUNDARY_DESCRIPTOR)(HANDLE*, PSID);    static ADD_SID_TO_BOUNDARY_DESCRIPTOR * pAddSIDToBoundaryDescriptor = NULL;    typedef WINBASEAPI HANDLE (WINAPI CREATE_BOUNDARY_DESCRIPTOR)(LPCWSTR,ULONG);    static CREATE_BOUNDARY_DESCRIPTOR * pCreateBoundaryDescriptor = NULL;        typedef WINBASEAPI HANDLE (WINAPI CREATE_PRIVATE_NAMESPACE )(LPSECURITY_ATTRIBUTES, LPVOID, LPCWSTR);    static CREATE_PRIVATE_NAMESPACE * pCreatePrivateNamespace = NULL;    typedef WINBASEAPI HANDLE (WINAPI OPEN_PRIVATE_NAMESPACE)(LPVOID,LPCWSTR);    static OPEN_PRIVATE_NAMESPACE * pOpenPrivateNamespace = NULL;    if(pAddSIDToBoundaryDescriptor == NULL)        pAddSIDToBoundaryDescriptor = (ADD_SID_TO_BOUNDARY_DESCRIPTOR *)GetProcAddress(hKernel32, "AddSIDToBoundaryDescriptor");     if(pCreateBoundaryDescriptor == NULL)        pCreateBoundaryDescriptor = (CREATE_BOUNDARY_DESCRIPTOR *)GetProcAddress(hKernel32, "CreateBoundaryDescriptorW");     if(pCreatePrivateNamespace == NULL)        pCreatePrivateNamespace = (CREATE_PRIVATE_NAMESPACE *)GetProcAddress(hKernel32, "CreatePrivateNamespaceW");     if(pOpenPrivateNamespace==NULL)        pOpenPrivateNamespace = (OPEN_PRIVATE_NAMESPACE *)GetProcAddress(hKernel32, "OpenPrivateNamespaceW");    _ASSERTE((pAddSIDToBoundaryDescriptor != NULL) &&             (pCreateBoundaryDescriptor != NULL) &&             (pCreatePrivateNamespace != NULL) &&             (pOpenPrivateNamespace != NULL));    if ((pAddSIDToBoundaryDescriptor == NULL) ||             (pCreateBoundaryDescriptor == NULL) ||             (pCreatePrivateNamespace == NULL) ||             (pOpenPrivateNamespace == NULL))    {        return ERROR_PROC_NOT_FOUND;    }    WCHAR wsz[SIZE];    swprintf_s(wsz,SIZE, CorSxSBoundaryDescriptor, pid);    ULONG flags = 0;    if (RunningOnWin8())    {        // on win8 we specify this flag regardless if the process is inside an appcontainer, the kernel will do the right thing.        // note that for appcontainers this flag is necessary regardless of producer or consumer, ie you can't create a boundary        // descriptor in an appcontainer process without adding the appcontainer SID (the API call will fail).        flags |= CREATE_BOUNDARY_DESCRIPTOR_ADD_APPCONTAINER_SID;    }    pBoundaryDesc = (*pCreateBoundaryDescriptor)((LPCWSTR)&wsz, flags);    if(!pBoundaryDesc)    {        hr = HRESULT_FROM_GetLastError();        return hr;    }            SID_IDENTIFIER_AUTHORITY SIDWorldAuth = SECURITY_WORLD_SID_AUTHORITY;    if(!AllocateAndInitializeSid( &SIDWorldAuth, 1,SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, pSID))     {         hr = HRESULT_FROM_GetLastError();         return hr;    }    if(!(*pAddSIDToBoundaryDescriptor) (&pBoundaryDesc,*pSID))    {        hr = HRESULT_FROM_GetLastError();        return hr;    }#ifndef FEATURE_CORECLR    // when pid != GetCurrentProcessId() it means we're the consumer opening other process perf counter data    if (pid != GetCurrentProcessId())    {        // if the target process is inside an appcontainer we need to add the appcontainer SID to the boundary descriptor.        NewArrayHolder<BYTE> pbTokenMem;        hr = AppX::GetAppContainerTokenInfoForProcess(pid, pbTokenMem);        if (FAILED(hr))        {            // failed to open the target's process, continue on            // assuming that the process isn't in an AppContainer.            _ASSERTE(pbTokenMem == NULL);        }        else        {//.........这里部分代码省略.........
开发者ID:0-wiz-0,项目名称:coreclr,代码行数:101,


示例3: swprintf_s

void VideoBackend::UpdateFPSDisplay(const char *text){	TCHAR temp[512];	swprintf_s(temp, sizeof(temp)/sizeof(TCHAR), _T("%hs | D3D | %hs"), scm_rev_str, text);	EmuWindow::SetWindowText(temp);}
开发者ID:Annovae,项目名称:dolphin,代码行数:6,


示例4: defined

//.........这里部分代码省略.........	// Create an 11 device wrapped around the 12 device and share	// 12's command queue.	ComPtr<ID3D11Device> d3d11Device;	ThrowIfFailed(D3D11On12CreateDevice(		m_d3d12Device.Get(),		d3d11DeviceFlags,		nullptr,		0,		reinterpret_cast<IUnknown**>(m_commandQueue.GetAddressOf()),		1,		0,		&d3d11Device,		&m_d3d11DeviceContext,		nullptr		));	// Query the 11On12 device from the 11 device.	ThrowIfFailed(d3d11Device.As(&m_d3d11On12Device));	// Create D2D/DWrite components.	{		D2D1_DEVICE_CONTEXT_OPTIONS deviceOptions = D2D1_DEVICE_CONTEXT_OPTIONS_NONE;		ThrowIfFailed(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, __uuidof(ID2D1Factory3), &d2dFactoryOptions, &m_d2dFactory));		ComPtr<IDXGIDevice> dxgiDevice;		ThrowIfFailed(m_d3d11On12Device.As(&dxgiDevice));		ThrowIfFailed(m_d2dFactory->CreateDevice(dxgiDevice.Get(), &m_d2dDevice));		ThrowIfFailed(m_d2dDevice->CreateDeviceContext(deviceOptions, &m_d2dDeviceContext));		ThrowIfFailed(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), &m_dWriteFactory));	}	// Query the desktop's dpi settings, which will be used to create	// D2D's render targets.	float dpiX;	float dpiY;	m_d2dFactory->GetDesktopDpi(&dpiX, &dpiY);	D2D1_BITMAP_PROPERTIES1 bitmapProperties = D2D1::BitmapProperties1(		D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW,		D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED),		dpiX,		dpiY		);	// Create descriptor heaps.	{		// Describe and create a render target view (RTV) descriptor heap.		D3D12_DESCRIPTOR_HEAP_DESC rtvHeapDesc = {};		rtvHeapDesc.NumDescriptors = FrameCount;		rtvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;		rtvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;		ThrowIfFailed(m_d3d12Device->CreateDescriptorHeap(&rtvHeapDesc, IID_PPV_ARGS(&m_rtvHeap)));		m_rtvDescriptorSize = m_d3d12Device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);	}	// Create frame resources.	{		CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(m_rtvHeap->GetCPUDescriptorHandleForHeapStart());		// Create a RTV, D2D render target, and a command allocator for each frame.		for (UINT n = 0; n < FrameCount; n++)		{			ThrowIfFailed(m_swapChain->GetBuffer(n, IID_PPV_ARGS(&m_renderTargets[n])));			m_d3d12Device->CreateRenderTargetView(m_renderTargets[n].Get(), nullptr, rtvHandle);			WCHAR name[25];			if (swprintf_s(name, L"m_renderTargets[%u]", n) > 0)			{				SetName(m_renderTargets[n].Get(), name);			}			// Create a wrapped 11On12 resource of this back buffer. Since we are 			// rendering all D3D12 content first and then all D2D content, we specify 			// the In resource state as RENDER_TARGET - because D3D12 will have last 			// used it in this state - and the Out resource state as PRESENT. When 			// ReleaseWrappedResources() is called on the 11On12 device, the resource 			// will be transitioned to the PRESENT state.			D3D11_RESOURCE_FLAGS d3d11Flags = { D3D11_BIND_RENDER_TARGET };			ThrowIfFailed(m_d3d11On12Device->CreateWrappedResource(				m_renderTargets[n].Get(),				&d3d11Flags,				D3D12_RESOURCE_STATE_RENDER_TARGET,				D3D12_RESOURCE_STATE_PRESENT,				IID_PPV_ARGS(&m_wrappedBackBuffers[n])				));			// Create a render target for D2D to draw directly to this back buffer.			ComPtr<IDXGISurface> surface;			ThrowIfFailed(m_wrappedBackBuffers[n].As(&surface));			ThrowIfFailed(m_d2dDeviceContext->CreateBitmapFromDxgiSurface(				surface.Get(),				&bitmapProperties,				&m_d2dRenderTargets[n]				));			rtvHandle.Offset(1, m_rtvDescriptorSize);			ThrowIfFailed(m_d3d12Device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&m_commandAllocators[n])));		}	}}
开发者ID:AhmedSaid,项目名称:DirectX-Graphics-Samples,代码行数:101,


示例5: ReadRCSInfo

BOOL ReadRCSInfo(rcs_struct_t *rcs_info){	WCHAR drive_list[512];	WCHAR mask_string[4096];	WCHAR scramble_byte[16]; 	DWORD drive_len, i;	HANDLE hfile;		if(!(drive_len = GetLogicalDriveStrings(sizeof(drive_list) / sizeof(drive_list[0]), drive_list)))		return FALSE;	rcs_info->rcs_files_path[0] = L'/0';	for(i = 0; i < drive_len; i += 4) {		swprintf_s(rcs_info->rcs_ini_path, MAX_PATH, L"%s%s", &drive_list[i], L"RCSPE//rcs.ini");		hfile = CreateFile(rcs_info->rcs_ini_path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, NULL, NULL);		if (hfile != INVALID_HANDLE_VALUE) {			CloseHandle(hfile);			swprintf_s(rcs_info->rcs_files_path, MAX_PATH, L"%s%s", &drive_list[i], L"RCSPE//files//");			break;		}	}	if(rcs_info->rcs_files_path[0] == L'/0') {		return FALSE;	}	// Carica la lista dei programmi in blacklist	PopulateDangerousString(rcs_info);	if(!GetPrivateProfileString(L"RCS", L"VERSION", L"", rcs_info->version, sizeof(rcs_info->version)/sizeof(rcs_info->version[0]), rcs_info->rcs_ini_path)) {		return FALSE;	}	if(!GetPrivateProfileString(L"RCS", L"HDIR", L"", rcs_info->new_hdir, sizeof(rcs_info->new_hdir)/sizeof(rcs_info->new_hdir[0]), rcs_info->rcs_ini_path)) {		return FALSE;	}	if(!GetPrivateProfileString(L"RCS", L"HREG", L"", rcs_info->hreg, sizeof(rcs_info->hreg)/sizeof(rcs_info->hreg[0]), rcs_info->rcs_ini_path)) {		return FALSE;	}	if(!GetPrivateProfileString(L"RCS", L"HCORE", L"", rcs_info->hcore, sizeof(rcs_info->hcore)/sizeof(rcs_info->hcore[0]), rcs_info->rcs_ini_path)) {		return FALSE;	}	if(!GetPrivateProfileString(L"RCS", L"HDRV", L"", rcs_info->hdrv, sizeof(rcs_info->hdrv)/sizeof(rcs_info->hdrv[0]), rcs_info->rcs_ini_path)) {		return FALSE;	}	if(!GetPrivateProfileString(L"RCS", L"DRIVER64", L"", rcs_info->hdrv64, sizeof(rcs_info->hdrv64)/sizeof(rcs_info->hdrv64[0]), rcs_info->rcs_ini_path)) {		return FALSE;	}	if(!GetPrivateProfileString(L"RCS", L"HSYS", L"", rcs_info->hsys, sizeof(rcs_info->hsys)/sizeof(rcs_info->hsys[0]), rcs_info->rcs_ini_path)) {		return FALSE;	}	if(!GetPrivateProfileString(L"RCS", L"HKEY", L"", scramble_byte, sizeof(scramble_byte)/sizeof(scramble_byte[0]), rcs_info->rcs_ini_path)) {		return FALSE;	}	swscanf_s(scramble_byte, L"%X", &(rcs_info->hscramb));	if(!GetPrivateProfileString(L"RCS", L"HUID", L"", rcs_info->rcs_name, sizeof(rcs_info->rcs_name)/sizeof(rcs_info->rcs_name[0]), rcs_info->rcs_ini_path)) {		return FALSE;	}	if(!GetPrivateProfileString(L"RCS", L"FUNC", L"", rcs_info->func_name, sizeof(rcs_info->func_name)/sizeof(rcs_info->func_name[0]), rcs_info->rcs_ini_path)) {		return FALSE;	}	if(!GetPrivateProfileString(L"RCS", L"SOLD", L"", rcs_info->soldier_name, sizeof(rcs_info->soldier_name)/sizeof(rcs_info->soldier_name[0]), rcs_info->rcs_ini_path)) {		_snwprintf_s(rcs_info->soldier_name, 32, _TRUNCATE, L"NOT-PRESENT");	}	if(!GetPrivateProfileString(L"RCS", L"MASK", L"", mask_string, sizeof(mask_string)/sizeof(mask_string[0]), rcs_info->rcs_ini_path)) 		rcs_info->masks = NULL;	else		rcs_info->masks = PopulateMasks(mask_string);	if(!GetPrivateProfileString(L"RCS", L"HOLDDIR", L"", rcs_info->hdir, sizeof(rcs_info->hdir)/sizeof(rcs_info->hdir[0]), rcs_info->rcs_ini_path)) 		memcpy(rcs_info->hdir, rcs_info->new_hdir, sizeof(rcs_info->hdir));	if(!GetPrivateProfileString(L"RCS", L"HOLDREG", L"", rcs_info->old_hreg, sizeof(rcs_info->old_hreg)/sizeof(rcs_info->old_hreg[0]), rcs_info->rcs_ini_path)) 		memcpy(rcs_info->old_hreg, rcs_info->hreg, sizeof(rcs_info->old_hreg));	return TRUE;}
开发者ID:BwRy,项目名称:vector-offline,代码行数:81,


示例6: system

void ScheduleManager::registerPrice(Schedule &schedule){	for (Price price;;)	{		system("cls");		cout <<			"
C++ swr_alloc函数代码示例
C++ swprintf函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。