gpt4 book ai didi

c++ - WinAPI 创建文件函数

转载 作者:太空狗 更新时间:2023-10-29 20:15:35 25 4
gpt4 key购买 nike

<分区>

我必须用 C++ 编写 CreateFile 函数我写了这个,但是没有用

#include <iostream>
#include <windows.h>
#include <string>
using namespace std;

int main()
{
HANDLE hfile = CreateFile(
".\temp.txt", // "\\.\C:"
GENERIC_READ,
0,
NULL,
CREATE_NEW,
FILE_ATTRIBUTE_NORMAL,
NULL);

//if (hFile == INVALID_HANDLE_VALUE) cout << "Unable to create file \n";
return 0;
}

error C2664: 'CreateFileW' : cannot convert parameter 1 from 'const char [10]' to 'LPCWSTR'

我该如何修复这个错误?

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