windows log 打印语句

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

 1 #ifdef _DEBUG
 2
 3 HANDLE hEventSource = NULL;
 4 LPCWSTR lpszStrings[2] = { NULL, NULL };
 5
 6 hEventSource = RegisterEventSourceW(NULL, L"DeviceMonitorService");
 7 if (hEventSource)
 8 {
 9 lpszStrings[0] = L"Source";//来源
10 lpszStrings[1] = pszMessage;
11
12 ReportEventW(hEventSource, // Event log handle
13 wType, // Event type
14 0, // Event category
15 0, // Event identifier
16 NULL, // No security identifier
17 2, // Size of lpszStrings array
18 0, // No binary data
19 lpszStrings, // Array of strings
20 NULL // No binary data
21 );
22
23 DeregisterEventSource(hEventSource);
24 }
25 #else
26 #endif // DEBUG

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

void logoutput(const char * lpszFormat, ...)
{
    //#ifdef _DEBUG

    va_list argList;
    va_start(argList, lpszFormat);

    char chInput[512] = { 0 };
    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

时间: 2024-08-01 22:54:19

windows log 打印语句的相关文章

去除console.log()打印语句

打印语句:console.log() ,一句话描述它! “用的时候感觉贼爽,不用的时候脑袋痛吧?” 以下提供两种解决方案: 一. webpack打包时去除,适合Vue项目 二. vscode正则匹配,手动去除 1. 拖放整个项目文件夹到vscode 2. 选中文件夹,然后编辑->在文件中替换 1. console.log()加了分号 console\.log\(.*?\); 2. console.log()没加分号 console\.log\(.*?\) 准备出一篇简单易懂的正则. 原文地址:h

Python<5>赋值、表达式、打印语句

赋值语句 绝大多数的赋值语句都很简单,但有些特性要专门记住: <1>赋值语句建立对象引用值 Python赋值语句会把对象引用值存储在变量名或者数据结构的元素内.赋值语句总是建立对象的引用值,而不是 复制对象,因此Python变量更像是指针,而不是数据存储区域. <2>变量名会在首次赋值时被创建 一旦赋值了,每当这个变量名出现在表达式时就会被其所引用的值取代. <3>变量名在引用前必须先赋值 否则可能发生异常 <4>执行隐式赋值时的一些操作 所有的赋值环境都是

andriod之log打印

先设置自己的log打印: 然后在activity类入口写log代码: 3:结果:

IOS 打印语句

打印width和height NSLog("width: %f, height: %f",self.View.frame.size.width, self.View.navigationBar.frame.size.height); 打印frame NSLog(@"%@",[NSValue valueWithCGRect:self.View.bounds]); IOS 打印语句

关于console.log() 打印得引用类型得数据得相关问题

console.log()打印出来得是这个引用类型最终得结果,而不是在打印得时候当前得值 var json = {a:1,b:2} console.log(json) json.a = 3; 如上  ,打印得将是  {a:3,b:2},而不是  {a:1,b:2} 解决方法,要么打断点,要么将需要输出得内容变成值类型输出

关于写入Windows Log Event却没有任何记录的问题

在本机或者服务器上,写入Windows Event Log日志代码,执行了没有报错,但是打开Windows Event Log记录面板,却看不到任何记录,很可能是你当前用户没有权限是写入东西.此时,我们做一些配置,就可以使当前用户拥有写入Event Log的权限. 设置:"开始->运行",输入命令,"regedt32",找到"System->CurrentControlSet->Services->Eventlog",选择

tiny4412 串口驱动分析七 --- log打印的几个阶段之内核启动阶段(earlyprintk)

作者:彭东林 邮箱:[email protected] 开发板:tiny4412ADK+S700 4GB Flash 主机:Wind7 64位 虚拟机:Vmware+Ubuntu12_04 u-boot:U-Boot 2010.12 Linux内核版本:linux-3.0.31 Android版本:android-4.1.2 下面要分析的是内核Log打印的几个阶段 自解压阶段 内核启动阶段 内核启动完全以后 shell终端下 在这个阶段内核log打印可以调用printk和printascii,同

idea中scala项目补全变量、添加打印语句的小技巧

1. 自动补全变量: new Person.var  ,然后按回车键:效果:代码变成: val person: Person = new Person 2.添加打印语句: person.name.prln (也可以是prtln) ,然后按回车键.效果,代码变成: println(person.name) 原文地址:https://www.cnblogs.com/mediocreWorld/p/11517231.html

使用console.log打印的内容不一定可信

在工作中遇到,使用console.log()输出对象信息时,出现输出的信息跟自己想的不一样的问题,导致调试bug时,思路走偏. 当时参考了别人的issues已经讲的很清楚了. 这里自己再记录一下 问题描述: 即使我直接在赋值语句const obj = {age: 20}后面紧跟console.log(obj), 在浏览器的控制台,看到的也不一定的age字段,也不一定是20. 因为,如果在后面的代码中,修改了age字段的值,那控制太看到的就不是20了. 比如执行如下代码: let obj = {a