Code:
#include <windows.h>
#include <shlobj.h>
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
int main()
{
char desktop_path[MAX_PATH];
// Get a token for this process.
HANDLE hToken;
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_IMPERSONATE | TOKEN_QUERY, &hToken))
{
cerr << "OpenProcessToken() failed, ec = " << GetLastError() << endl;
return 1;
}//if
// Get the desktop folder for the user of this process
HRESULT res = SHGetFolderPathA(NULL, CSIDL_DESKTOPDIRECTORY,
hToken, 0, desktop_path);
CloseHandle(hToken);
if (!SUCCEEDED(res))
{
cerr << "SHGetFolderPathA() failed, ec = " << GetLastError() << endl;
return 2;
}//if
strcat(desktop_path, "\\Scorse.txt");
ofstream touch(desktop_path);
touch.close();
cout << desktop_path << endl;
return 0;
}//main
gg