GetOpenFileName触发断点
GetOpenFileName triggers breakpoint
本文关键字:断点 GetOpenFileName 更新时间:2023-10-16
我正试图调用GetOpenFileName,如下所示:
int main(int argc, char* argv[])
{
OPENFILENAME ofn; // common dialog box structure
wchar_t szFile[260]; // buffer for file name
HWND hwnd; // owner window
HANDLE hf; // file handle
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
wchar_t title[500]; // to hold title
GetConsoleTitle( title, 500 );
HWND hwndConsole = FindWindow( NULL, title );
ofn.hwndOwner = hwndConsole;
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = ' ';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = L"All *.* Text *.TXT ";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
// Display the Open dialog box.
if (GetOpenFileName(&ofn)==TRUE)
hf = CreateFile(ofn.lpstrFile,
GENERIC_READ,
0,
(LPSECURITY_ATTRIBUTES) NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
(HANDLE) NULL);
程序在"if(GetOpenFileName(&non)==TRUE)"处停止(消息:example.exe已触发断点(而不是我放置的断点)。如果我没有中断,只是按continue,对话框就会弹出并按预期工作。我做错了什么?我刚刚注意到它在发布模式下工作没有问题。。。
一个可能的问题:ofn.nMaxFile
应该是字符数,而不是缓冲区的字节大小。试试这个:
ofn.nMaxFile = sizeof(szFile) / sizeof(wchar_t);
相关文章:
- 无法删除指针,已触发断点
- 条件断点在不应该触发时触发
- GDB 断点在 Mac 上是不准确的
- 在 vscode 中运行时无法暂停或设置断点
- 不会命中此断点
- 当前不会命中断点。没有调试器目标代码类型的可执行代码与此文件关联
- 如何在进入动态打开的共享库时设置断点?
- 为什么断点显示数组的第二个值是一个大数字?额外学分工作
- 代码在 msvcrt .dll函数上设置断点失败
- 如何在引用上设置数据断点
- 无法在visual studio 2017(本机c++)中禁用数据断点
- 为什么在c++中使用Delete[]会出现跟踪/断点错误
- for循环的条件只有在遇到断点后才生效
- 项目名称.exe 已触发断点
- 视觉对象触发了断点 c++
- 实现在多线程代码中安全恢复的断点
- 如何在 gdb 中的所有构造函数上同时为 C++ 对象设置断点?
- C/C++ 经过的流程周期,不包括断点处
- 在 Visual Studio 2012 中未命中断点
- 无法在 XmlHttpRequest 模块上获取断点(Javascript 引擎/XHR 请求)