Nov 26, 2019 01:34 PM
(This post was last modified: Nov 26, 2019 01:34 PM by pms.)
Im trying to convert my TCHAR to a string to i can create a file on the desktop of a computer, by using std::ofstream.
code currently -
i tried researching on google but i could not manadge to do it.
if anyone out there can help, im willing to send over some bytes, or couple of dollas.
code currently -
Code
/*
What am i trying to do here? -
--- I'm trying to simply create a file on the desktop
Whats my problem? -
--- I cant seem to convert TCHAR to a string(i have no idea how)
help plz <3
*/
#include <iostream>
#include <Windows.h>
#include <tchar.h>
#include <shlobj.h> // for SHGetFolderPath
#include <fstream>
#include <stdlib.h>
#include <string>
class createFile {
public:
void fileCreation(std::string file) {
std::ofstream f(file); // trying to create a file on the desktop
}
};
int main(int argc, _TCHAR* argv[]) // code down below is code im trying my hardest to understand
{
TCHAR path[_MAX_PATH] = _T("");
HRESULT hr = SHGetFolderPath(NULL, CSIDL_DESKTOP, 0, NULL, path);
if (SUCCEEDED(hr)) {
#ifdef _UNICODE
std::wcout << L"Desktop path = " << path << std::endl;
#else
std::cout << "Desktop path = " << path << endl;
#endif
}
createFile file;
file.fileCreation(path);
}i tried researching on google but i could not manadge to do it.
if anyone out there can help, im willing to send over some bytes, or couple of dollas.

