So i want to make a sort of texteditor and want to use a dialogwindow to get the filepath/file from the user. Now here is the problem. I get an error in one project that i does not get in another even though i have not changed a setting that would let me conclude that there might be an issue.
#include <Windows.h>
#include <fstream>
#include <Windows.h>
#include <string>
#include <iostream>
#include <stdlib.h>
#include <commdlg.h>
using std::cout;
void getfile() {
OPENFILENAME NameOfFile;
ZeroMemory(&NameOfFile, sizeof(NameOfFile));
NameOfFile.lStructSize = sizeof(NameOfFile);
LPWSTR szFile{};
NameOfFile.lpstrFile = szFile;
NameOfFile.nMaxFile = sizeof(szFile);
NameOfFile.Flags = OFN_ALLOWMULTISELECT;
if (GetOpenFileName(&NameOfFile))
{
std::cout << szFile;
}
}
int main() {
getfile();
}
When i do this in one project the error "Severity Code Description Project File Line Suppression state Error (active) E0513 A value of type ""LPWSTR"" cannot be assigned to an entity of type ""LPSTR"""
Picture of the working project
Here the settings of the project its not working
That is kinda understandable and i tried multiple workarounds with LPTSTR or triying .c_str() to convert but it wont work. And as i said the literally completly same code compiles and runs fine in another project