GetOpenFileName - 已触发断点

时间:2016-09-22 22:47:43

标签: c++ winapi

我想在C ++中通过WinAPI编写简单的OpenFile对话框。当我想调用GetOpenFileName时出现问题,我得到错误'test.exe已触发断点',即使我使用MSDN中的示例。

#include <Windows.h>

int main(int argc, char** argv)
{
    OPENFILENAME ofn;
    char szFile[260];  

    ZeroMemory(&ofn, sizeof(ofn));
    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = NULL;
    ofn.lpstrFile = szFile;
    ofn.lpstrFile[0] = '\0';
    ofn.nMaxFile = sizeof(szFile);
    ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
    ofn.nFilterIndex = 1;
    ofn.lpstrFileTitle = NULL;
    ofn.nMaxFileTitle = 0;
    ofn.lpstrInitialDir = NULL;
    ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

    GetOpenFileName(&ofn);
    return 0;
}

我正在使用VisualStudio 2015社区和Windows 10。

调用堆栈:

> KernelBase.dll!762882b2()   Unknown
  [Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll]    
  GROOVEEX.DLL!5891738e() Unknown
  GROOVEEX.DLL!588efb8d() Unknown
  GROOVEEX.DLL!587c548c() Unknown
  GROOVEEX.DLL!5879b0c5() Unknown
  GROOVEEX.DLL!5879b030() Unknown
  [External Code]

0 个答案:

没有答案