1、格式化字符串(Writes formatted data to the specified string)

  wchar_t szMessage[260];

  PWSTR pszFunction = L“Hello world !”;

  DWORD dwError = GetLastError();

  StringCchPrintfW(szMessage, ARRAYSIZE(szMessage),L"%s failed w/err 0x%08lx", pszFunction, dwError);

  StringCchPrintf is a replacement for the following functions:

2、ReportEventW ,适用于服务应用,适用于在事件查看器中查看相关log

 #ifdef _DEBUG

 HANDLE hEventSource = NULL;
LPCWSTR lpszStrings[] = { NULL, NULL }; hEventSource = RegisterEventSourceW(NULL, L"DeviceMonitorService");
if (hEventSource)
{
lpszStrings[] = L"Source";//来源
lpszStrings[] = pszMessage; ReportEventW(hEventSource, // Event log handle
wType, // Event type
, // Event category
, // Event identifier
NULL, // No security identifier
, // Size of lpszStrings array
, // No binary data
lpszStrings, // Array of strings
NULL // No binary data
); DeregisterEventSource(hEventSource);
}
#else
#endif // DEBUG

3、OutputDebugStringA,适用于win32应用程序(非控制台程序)

void logoutput(const char * lpszFormat, ...)
{
//#ifdef _DEBUG va_list argList;
va_start(argList, lpszFormat); char chInput[] = { };
vsprintf_s(chInput, lpszFormat, argList); va_end(argList); OutputDebugStringA(chInput);
OutputDebugStringA("\n"); //#endif
}

4、字符串操作(strsafe function)

The string functions give applications the means to copy, compare, sort, format, and convert character strings as well as the means to determine the character type of each character in a string.

使用安全字符:

  #include Strsafe.h

  StringCchCopy

CRT String Function Windows String Function StrSafe Function
strcat lstrcat
StringCchCat
StringCchCatEx
StringCbCat
StringCbCatEx
strcmp lstrcmp (no equivalent function)
strcpy lstrcpy
StringCchCopy
StringCchCopyEx
StringCbCopy
StringCbCopyEx
strlen lstrlen
StringCchLength
StringCbLength

来源于http://msdn.microsoft.com/en-us/library/windows/desktop/ms647465(v=vs.85).aspx

最新文章

  1. Appfuse:添加自定义页面组件
  2. Android 之 ProgressDialog用法介绍
  3. java实现甘特图的2种方法:SwiftGantt和Jfree (转)
  4. js区分鼠标单双击 阻止事件冒泡
  5. document.createElement()的用法<> 加强我对陌生代码的理解!
  6. ios开发中的toll-free bridged
  7. Valgrind使用[转]
  8. Nginx报错:Sorry, the page you are looking for is currently unavailable. Please try again later.
  9. Tomcat 官网知识总结篇
  10. Windows下FFmpeg快速入门 <第二篇>
  11. C++游戏编程(一开篇)
  12. sass 安装和使用
  13. Android中Edittext的属性
  14. java与javac的区别
  15. 11、借助POI实现Java生成并打印excel报表(2)
  16. ruby正则表带式对象使用备忘
  17. DokuWiki的发现之旅
  18. 使用Feign调用服务的问题
  19. 骚气男孩saochi boy 唐砖 插曲
  20. 利用Screen重启DevStack服务

热门文章

  1. CSS3伪类和伪元素的特性和区别
  2. Android 学习笔记之Volley开源框架解析(四)
  3. Linux下修改PATH路径
  4. [操作系统实验lab3]实验报告
  5. [Bootstrap]7天深入Bootstrap(4)CSS组件
  6. rightTeam SCRUM第一个冲刺周期
  7. P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1
  8. 克隆复制可使用原型( Prototype)设计模式
  9. Servelet面试题
  10. 重新想象 Windows 8 Store Apps (52) - 绑定: 与 Element Model Indexer Style RelativeSource 绑定, 以及绑定中的数据转换