ShellExecute is not working
Hi,
I need to get the Domain name of machine. As we use "whoami" command in cmd.exe to find the domain name, I did the same using code. but somehow the command.out file is not generating on my machine.
I wrote following code:
std::string currentUserInfo("");
std::string sCmdStr("WHOAMI>E:\command.out"); //output e.g. domainname\username
std::wstring wstr(sCmdStr.begin(), sCmdStr.end());
LPCWSTR lpCmdStr = wstr.c_str();
//windows func to execute command
ErrorCode error = kFailure;
ShellExecute(NULL, NULL, L"cmd.exe", lpCmdStr, NULL, SW_HIDE);
//this code will get user info from command.out
using std::ifstream;
ifstream ifs("E:\command.out");
std::getline(ifs, currentUserInfo);
ifs.close();
/**************************************************************************************************/
Application is not showing any error but command.out file is not generating. Once I compiled my code using "All platform" in project properties. and it worked but now with the same settings it is not working. my machine is 64bit and I usually compile my code on Visual studio 2008 32 bit platform.
Please let me know if anyone have idea about this.
Thanks in advance,
