Commits

Anonymous committed 2161cd9

Add variable for ospy file

Comments (0)

Files changed (1)

         ExitProcess(1);
 
     /* get paths */
-    GetModuleFileName(mainDll, requestedapplication, sizeof(requestedapplication));
     GetModuleFileName(mainDll, exefile, sizeof(exefile));
 
-    /* check if we have a Python library relative to the DLL home */
-    i = finddir(requestedapplication);
-    strncpy_s(requestedapplication + i, sizeof requestedapplication - i, lib_os_py, sizeof lib_os_py);
+    {
+        char ospyfile[512];
+        GetModuleFileName(mainDll, ospyfile, sizeof(ospyfile));
+        /* check if we have a Python library relative to the DLL home */
+        i = finddir(ospyfile);
+        strncpy_s(ospyfile + i, sizeof ospyfile - i, lib_os_py, sizeof lib_os_py);
 
-    {
-        HANDLE ospy = CreateFile(requestedapplication, GENERIC_READ, FILE_SHARE_READ, NULL,
-                                 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+        {
+            HANDLE ospy = CreateFile(ospyfile, GENERIC_READ, FILE_SHARE_READ, NULL,
+                                     OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
 
-        if (ospy != (HANDLE) -1) {
-            /* lib/os.py exists; set PYTHONHOME to the DLL directory */
-            Py_SetPythonHome = (void*) GetProcAddress(mainDll, "Py_SetPythonHome");
-            if (Py_SetPythonHome) {
-                requestedapplication[i] = '\0';
-                Py_SetPythonHome(requestedapplication); /* SetPythonHome keeps a reference! */
+            if (ospy != (HANDLE) -1) {
+                /* lib/os.py exists; set PYTHONHOME to the DLL directory */
+                Py_SetPythonHome = (void*) GetProcAddress(mainDll, "Py_SetPythonHome");
+                if (Py_SetPythonHome) {
+                    ospyfile[i] = '\0';
+                    Py_SetPythonHome(ospyfile); /* SetPythonHome keeps a reference! */
+                }
+                CloseHandle(ospy);
             }
-            CloseHandle(ospy);
         }
     }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.