使用 EvtSetChannelConfigProperty() 函数时出现访问冲突错误
Access violation error while using EvtSetChannelConfigProperty() function
>我正在尝试使用EvtSetChannelConfigProperty()
功能。我在运行程序时收到访问冲突。
我在管理员模式下运行Visual Studio。它仍然显示访问冲突。
我添加了<winevt.h>
头文件:
PEVT_VARIANT value;
UINT64 val = 30000000;
value = PEVT_VARIANT(val);
EVT_HANDLE hlog = EvtOpenChannelConfig(NULL,L"Application",0);
BOOL check = EvtSetChannelConfigProperty(hlog,EvtChannelLoggingConfigMaxSize, 0, value);
为什么我收到一条错误消息,指出读取位置时存在访问冲突?
错误:
'Windows_API.exe' (Win32): Loaded
'C:UsersAdministratorsourcereposWindows_APIx64DebugWindows_API.exe'.
Symbols loaded.
'Windows_API.exe' (Win32): Loaded 'C:WindowsSystem32ntdll.dll'. Cannot
find or open the PDB file.
'Windows_API.exe' (Win32): Loaded 'C:WindowsSystem32kernel32.dll'. Cannot
find or open the PDB file.
'Windows_API.exe' (Win32): Loaded 'C:WindowsSystem32KernelBase.dll'.
Cannot find or open the PDB file.
'Windows_API.exe' (Win32): Loaded 'C:WindowsSystem32apphelp.dll'. Cannot
find or open the PDB file.
'Windows_API.exe' (Win32): Loaded 'C:WindowsSystem32advapi32.dll'. Cannot
find or open the PDB file.
'Windows_API.exe' (Win32): Loaded 'C:WindowsSystem32msvcrt.dll'. Cannot
find or open the PDB file.
'Windows_API.exe' (Win32): Loaded 'C:WindowsSystem32sechost.dll'. Cannot
find or open the PDB file.
'Windows_API.exe' (Win32): Loaded 'C:WindowsSystem32rpcrt4.dll'. Cannot
find or open the PDB file.
'Windows_API.exe' (Win32): Loaded 'C:WindowsSystem32msvcp140d.dll'.
Cannot find or open the PDB file.
'Windows_API.exe' (Win32): Loaded 'C:WindowsSystem32ucrtbased.dll'.
Cannot find or open the PDB file.
'Windows_API.exe' (Win32): Loaded 'C:WindowsSystem32vcruntime140d.dll'.
Cannot find or open the PDB file.
'Windows_API.exe' (Win32): Unloaded 'C:WindowsSystem32vcruntime140d.dll'
'Windows_API.exe' (Win32): Loaded 'C:WindowsSystem32vcruntime140d.dll'.
Cannot find or open the PDB file.
'Windows_API.exe' (Win32): Loaded 'C:WindowsSystem32wevtapi.dll'. Cannot
find or open the PDB file.
'Windows_API.exe' (Win32): Loaded 'C:WindowsSystem32bcrypt.dll'. Cannot
find or open the PDB file.
Exception thrown at 0x00007FFBB52C6749 (wevtapi.dll) in Windows_API.exe:
0xC0000005: Access violation reading location 0x0000000001C9C38C.
The program '[7672] Windows_API.exe' has exited with code 0 (0x0).
value
是一个未初始化的指针器,无处可去。因此,当EvtSetChannelConfigProperty
尝试取消引用该指针时,程序会崩溃。
你可能想要这样的东西:
EVT_VARIANT value;
value.Count = 0;
value.Type = EvtVarTypeUInt64;
value.UInt64Val = 3000000;
EVT_HANDLE hlog = EvtOpenChannelConfig(NULL, L"Application", 0);
BOOL check = EvtSetChannelConfigProperty(hlog, EvtChannelLoggingConfigMaxSize, 0, &value);
顺便说一句,您无需为此处于管理员模式。
相关文章:
- 使用 EvtSetChannelConfigProperty() 函数时出现访问冲突错误
- cv::resize() 失败并出现访问冲突错误(由 NULL> 处的 <struct 引起)
- 将 std::string 作为参数从一个 DLL 传递到另一个 DLL 引发访问冲突错误
- 遵循官方 Direct2D 示例,但出现访问冲突错误
- C++ 抛出读取访问冲突错误,但我不确定为什么。平铺滑块益智游戏
- 为什么我的顶点缓冲区对象出现访问冲突错误?
- 销毁 Box2D 主体 - 读取访问冲突错误
- 编译哈希算法时出现内存访问冲突错误
- 使用glCreateBuffers时发生访问冲突错误
- 访问冲突错误在 (而 (info[x] != ))
- 反转字符串 c++ 时出现访问冲突错误
- 我无法弄清楚此访问冲突错误.有人可以在这里帮助我吗?
- 使用内存访问冲突错误
- 读取字符串的字符时出错-访问冲突错误C++
- 创建链接列表时发生访问冲突错误
- 调试优先级队列程序时出现访问冲突错误
- C++LinkedList错误:访问冲突错误
- 为什么我在用SDL2_ttf填充文本时出现访问冲突错误
- MFC:在工作线程中使用对象的成员函数时获取访问冲突错误
- 在C++中使用Box2D物理退出游戏时出现访问冲突错误