0
|
1 #include <windows.h>
|
|
2 #include <stdio.h>
|
|
3 #include <tchar.h>
|
|
4 #include <stdlib.h> // exit
|
|
5 #include <unistd.h> // sleep access
|
|
6
|
|
7 char * file_exist(){
|
|
8 char * name = (char *)".\\config.txt";
|
|
9 //char *file = current(name);
|
|
10 char *file = name;
|
|
11
|
|
12 if (access(file, F_OK)==0){
|
|
13 printf("PLIK istnieje %s\n",file);
|
|
14 //free(file);
|
|
15 return file;
|
|
16 }
|
|
17 printf("PLIK nie istnieje %s\n",file);
|
|
18 //free(file);
|
|
19 return NULL;
|
|
20 }
|
|
21
|
|
22
|
|
23
|
|
24
|
5
|
25 void _main( int argc, TCHAR *argv[] )
|
0
|
26 {
|
|
27 STARTUPINFO si;
|
|
28 PROCESS_INFORMATION pi;
|
|
29
|
|
30 char * file = file_exist();
|
|
31 char bufor1[128];
|
|
32 char bufor2[128];
|
|
33 char bufor3[128];
|
|
34 char run[384];
|
|
35
|
|
36 if (!file) exit(1);
|
|
37
|
|
38 FILE * f = fopen(file, "r");
|
|
39 fscanf(f, "%s %s %s", bufor1,bufor2,bufor3);
|
|
40 fclose(f);
|
|
41 strcpy(run, bufor1);
|
|
42 strcat(run, " ");
|
|
43 strcat(run, bufor2);
|
|
44 strcat(run, " ");
|
|
45 strcat(run, bufor3);
|
|
46 printf("Uruchamiam %s \n",run);
|
|
47 //free(file);
|
|
48
|
|
49
|
|
50 ZeroMemory( &si, sizeof(si) );
|
|
51 si.cb = sizeof(si);
|
|
52 ZeroMemory( &pi, sizeof(pi) );
|
|
53
|
|
54 //if( argc != 2 )
|
|
55 //{
|
|
56 // printf("Usage: %s [cmdline]\n", argv[0]);
|
|
57 // return;
|
|
58 //}
|
|
59
|
|
60 // Start the child process.
|
|
61 if( !CreateProcess( NULL, // No module name (use command line)
|
|
62 run, // Command line
|
|
63 NULL, // Process handle not inheritable
|
|
64 NULL, // Thread handle not inheritable
|
|
65 FALSE, // Set handle inheritance to FALSE
|
|
66 0, // No creation flags
|
|
67 NULL, // Use parent's environment block
|
|
68 NULL, // Use parent's starting directory
|
|
69 &si, // Pointer to STARTUPINFO structure
|
|
70 &pi ) // Pointer to PROCESS_INFORMATION structure
|
|
71 )
|
|
72 {
|
|
73 printf( "CreateProcess failed (%d).\n", GetLastError() );
|
|
74 return;
|
|
75 }
|
|
76
|
|
77 // Wait until child process exits.
|
|
78 WaitForSingleObject( pi.hProcess, INFINITE );
|
|
79
|
|
80 // Close process and thread handles.
|
|
81 CloseHandle( pi.hProcess );
|
|
82 CloseHandle( pi.hThread );
|
|
83 }
|