diff immposiblerush/win32/wrapper.c @ 0:2787f5e749ae

INIT
author prymula <prymula76@outlook.com>
date Thu, 21 Sep 2023 22:33:57 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/immposiblerush/win32/wrapper.c	Thu Sep 21 22:33:57 2023 +0200
@@ -0,0 +1,83 @@
+#include <windows.h>
+#include <stdio.h>
+#include <tchar.h>
+#include <stdlib.h>  // exit
+#include <unistd.h>  // sleep  access
+
+char * file_exist(){
+    char * name = (char *)".\\config.txt";
+	//char *file = current(name);
+	char *file = name;
+
+	if (access(file, F_OK)==0){
+		printf("PLIK istnieje %s\n",file);
+		//free(file);
+		return file;
+	}
+	printf("PLIK nie istnieje %s\n",file);
+	//free(file);
+	return NULL;
+}
+
+
+
+
+void main( int argc, TCHAR *argv[] )
+{
+    STARTUPINFO si;
+    PROCESS_INFORMATION pi;
+
+	char * file = file_exist();
+	char bufor1[128];
+    char bufor2[128];
+    char bufor3[128];
+    char run[384];
+
+	if (!file) exit(1);
+
+	FILE * f = fopen(file, "r");
+	fscanf(f, "%s %s %s", bufor1,bufor2,bufor3);
+	fclose(f);
+    strcpy(run, bufor1);
+    strcat(run, " ");
+    strcat(run, bufor2);
+    strcat(run, " ");
+    strcat(run, bufor3);
+    printf("Uruchamiam %s \n",run);
+    //free(file);
+
+
+    ZeroMemory( &si, sizeof(si) );
+    si.cb = sizeof(si);
+    ZeroMemory( &pi, sizeof(pi) );
+
+    //if( argc != 2 )
+    //{
+    //    printf("Usage: %s [cmdline]\n", argv[0]);
+   //    return;
+    //}
+
+    // Start the child process. 
+    if( !CreateProcess( NULL,   // No module name (use command line)
+        run,        // Command line
+        NULL,           // Process handle not inheritable
+        NULL,           // Thread handle not inheritable
+        FALSE,          // Set handle inheritance to FALSE
+        0,              // No creation flags
+        NULL,           // Use parent's environment block
+        NULL,           // Use parent's starting directory 
+        &si,            // Pointer to STARTUPINFO structure
+        &pi )           // Pointer to PROCESS_INFORMATION structure
+    ) 
+    {
+        printf( "CreateProcess failed (%d).\n", GetLastError() );
+        return;
+    }
+
+    // Wait until child process exits.
+    WaitForSingleObject( pi.hProcess, INFINITE );
+
+    // Close process and thread handles. 
+    CloseHandle( pi.hProcess );
+    CloseHandle( pi.hThread );
+}