I am trying to combine two strings in order to complete a path to a file, but I encountered 100s of errors trying to accomplish that, I am a new C++ programmer, because I program mainly on VB.net. See, VB.net has limitations so I decided to modify a program that is written in C++ because it cannot be converted to Vb.net.
Here are the codes of a program called ClamAVGUI, it is a old GUI for the antivirus programm ClamWin. this is the CPP file of the project, it is just an exceprt. I am trying to do is this, The program has checkboxes, each
checkboxes has a command, like for example, If i checked a box named, "Log the Scan" the program will append to the CLI exe, the ff. clamscan.exe "--log=PATH TO LOG FILE", this is what I am trying to d now,
but I need to find the program on where it is, for example finding its %HOMEDRIVE% where it is installed, for ex. at drive "C:\", then I will add the ff. commands to make the program work,
GetEnvironmentValue("homedrive") += """\\ClamAV\\Logs\\logfile.log", but I cannot do this in C++. Please help me, and guide me, I've trying this for hours and still no conclusion.
I don't know if this is a MFC app, I don't how to idenfity C++ program types, please guide me. Thank You.
std::string cmdArg;
std::string strcmd1 = "--log=";
std::string strcmd2 = GetEnvironmentValue("HOMEDRIVE");
std::string strcmd3 = "\CLamAV\logs\Scan.log";
cmdArg.append(strcmd1);
cmsArg.append(strcmd2);
cmdArg.append(strcmd3);
const char * GetEnvironmentValue(const char * name)
{
const DWORD buffSize = 65535;
static char buffer[buffSize];
if (GetEnvironmentVariableA(name, buffer, buffSize))
{
return buffer;
}
else
{
return 0;
}
}
static Option options[] =
{
{ "--recursive", IDC_RECURSE },
{ "--remove", IDC_RADIO1 },
{ "-i", IDC_ONLYINFECTED },
{ "--no-summary ", IDC_NOSUMMARY },
{ "--bell", IDC_BEEP },
{ " ", IDC_REPORT },
{ "--database="".\\db""", IDC_db }, {"--log=" += GetEnvironmentValue("HOMEDRIVE") += "\CLamAV\logs\Scan.log", IDC_LOGSCAN},
{ NULL, 0 }
};
-------------------------------UPDATED----------------------------------
Okay I managed to combine two strings by using the ff code:
char testString1[200];
char testString2[100];
strcpy(testString2,buffer);
strcpy(testString1,"--tempdir=""");
strcat(testString1, testString2);
static Option options[] =
{
};
Then another problem arises, ERROR: IntelliSense: this declaration has no storage class or type specifier
I cannot paste it outside, but I can if it is in a another function.