Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string shell(string program, string command, int rm=-1)
- {
- LPTSTR prog, windir;
- GetWindowsDirectory(windir, MAX_PATH);
- if(program.find(":")==string::npos)
- {
- program = string(windir)+"\\System32\\"+program;
- }
- prog = (LPTSTR) program.c_str();
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
- SECURITY_ATTRIBUTES sec;
- ZeroMemory( &si, sizeof(si));
- si.cb = sizeof(si);
- ZeroMemory( &pi, sizeof(pi));
- ZeroMemory( &sec, sizeof(sec));
- sec.nLength = sizeof(sec);
- sec.lpSecurityDescriptor = NULL;
- sec.bInheritHandle = FALSE;
- MessageBox(NULL, (char*) windir, program.c_str(), 0);
- if(CreateProcess((LPCTSTR) prog , "/c dir", NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)==0)
- {
- char* serr;
- sprintf(serr, "CreateProcess failed (%d)\n", GetLastError());
- MessageBox(NULL, "testicles", "error", MB_ICONERROR);
- return string(serr);
- }
- MessageBox(NULL, "testarin", "error", MB_ICONERROR);
- return "";
- }
Add Comment
Please, Sign In to add comment