Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

Convert TCHAR to string ?

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 -
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.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by MordiciaNov 15, 2019 07:21 PM 3 211 Nov 15, 2019 07:21 PM
Last Post: Mordicia
[C] by ApexLeadNov 26, 2018 08:33 AM 1 117 Nov 26, 2018 08:33 AM
Last Post: HFDone
[Java] by pureaccaMay 12, 2017 12:57 PM 10 609 May 12, 2017 12:57 PM
Last Post: ComplexEternity