I created a program in c++ when i build it using VS C++ 2012 using release mode with
Runtime Library: "MultiThreaded(/MT)
Then its captured by avast antivirus as virus. But if i change Runtime Library to "MultiThreaded DLL(/MD)" then avast don't capture it as virus.
Here is code
LPWSTR _GetUserName();
void FileWriteLine(LPCWSTR filePath,LPCWSTR line);
int main()
{
LPCWSTR userName = _GetUserName();
FileWriteLine(userName,L"Hello World");
return 1;
}
void FileWriteLine(LPCWSTR filePath,LPCWSTR line)
{
wfstream fileHandle(filePath,ios::out | ios::app);
fileHandle << line<<endl;
fileHandle.close();
}
LPWSTR _GetUserName()
{
LPWSTR username = new TCHAR[257];
DWORD size = 257;
if (!GetUserNameW(username,&size))
{
username = _wgetenv(L"USERNAME");
if (username == NULL)
{
username = L"Error-Unknown";
}
}
return username;
}