#include #include using namespace std; int main (int argc, char * * argv) { cout << "Start" << endl; STARTUPINFO startup; memset (&startup, 0, sizeof (startup)); PROCESS_INFORMATION info; BOOL ok = CreateProcess ( NULL, // LPCTSTR lpApplicationName, "notepad pokus.txt", // LPTSTR lpCommandLine, NULL, // LPSECURITY_ATTRIBUTES lpProcessAttributes, NULL, // LPSECURITY_ATTRIBUTES lpThreadAttributes, FALSE, // BOOL bInheritHandles, 0, // DWORD dwCreationFlags, NULL, // LPVOID lpEnvironment, "c:\\work", // LPCTSTR lpCurrentDirectory, & startup, // LPSTARTUPINFO lpStartupInfo, & info // LPPROCESS_INFORMATION lpProcessInformation ); if (ok) cout << "O.K." << endl; else { int code = GetLastError (); cout << "Error code: " << code << endl; char * answer = "nic"; FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM /* | FORMAT_MESSAGE_IGNORE_INSERTS */, // DWORD dwFlags NULL, // LPCVOID lpSource, code , // DWORD dwMessageId, 0, // DWORD dwLanguageId, (LPTSTR) & answer, // LPTSTR lpBuffer, 0, // DWORD nSize, NULL // va_list* Arguments ); cout << "Error: " << answer << endl; } cout << "Stop" << endl; char s [2]; cin.getline (s, sizeof (s)); return 0; }