1

I want concat the string -jar to left side of a path the is C:\Users\NZT48\AppData\Roaming where final result must be like:

-jar C:\Users\NZT48\AppData\Roaming

Have tried with code below, but when concatenates the path with the string -jar is overwritting and stays only the string of path.

#include "stdafx.h"
#include <conio.h>
#include <tchar.h>
#include <Windows.h>
#include <shlobj.h>
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{

    TCHAR argjar[MAX_PATH];

    TCHAR szRoaming[MAX_PATH];
    HRESULT hRoaming = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, szRoaming);

    if (!SUCCEEDED(hRoaming))
    {
        printf("SHGetFolderPath function failed.\n");
    }

    wsprintf(argjar, TEXT("%S -jar "), argjar);
    wsprintf(argjar, szRoaming , argjar);  // My problem is here

    printf("%S\n", argjar);

    _getch();
    return 0;
}

0 Answers0