gpt4 book ai didi

c++ - 控制转移绕过 : 的初始化

转载 作者:行者123 更新时间:2023-11-30 05:18:37 28 4
gpt4 key购买 nike

<分区>

基本上,我尝试使用 OPENFILENAME 打开一个 txt 文件,但它会输出文件的目录。我想让它输出txt文件的内容。

我的代码有问题;这是:

OPENFILENAME ofn;
char szFile[100];

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);

std::string line = " ";

fstream infile;
infile.open(ofn.lpstrFile);

Print(ofn.lpstrFile);

这会产生一个错误:
error

所有帮助将不胜感激,谢谢。

std::string line = " ";

fstream infile;
infile.open(ofn.lpstrFile);

Print(ofn.lpstrFile);

是问题所在。

编辑:

LRESULT CALLBACK DLLWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_COMMAND:
switch (wParam)
{
case MYMENU_OPENSCRIPT:
OPENFILENAME ofn;
char szFile[100];

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);

std::string line = " ";

fstream infile;
infile.open(ofn.lpstrFile);

Print(ofn.lpstrFile);

break;

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com