The trunk version of wxLua won't run on pre-XP systems because it depends on AttachConsole in kernel32 (introduced in XP). The attached patch only calls AttachConsole if it is available.

Index: wxlconsole.cpp
===================================================================
--- wxlconsole.cpp      (revision 178)
+++ wxlconsole.cpp      (working copy)
@@ -26,6 +26,7 @@
 #include <wx/filename.h>
 #include <wx/numdlg.h>
 #include <wx/artprov.h>
+#include <wx/dynlib.h>
 
 #include "wxlua/wxlua.h"
 #include "wxlconsole.h"
@@ -278,9 +279,24 @@
     memset(&coninfo, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFO));
     FILE *fp = 0; // we don't close this, let the OS close it when the app 
exits
 
-    // Try to attach to the parent process if it's a console, i.e. we're run 
from a DOS prompt.
-    BOOL attached_ok = AttachConsole( ATTACH_PARENT_PROCESS );
+       wxDynamicLibrary kernel;
+       //Dynamically load kernel32 because AttachConsole is not supported 
pre-XP
+       BOOL attached_ok = kernel.Load(wxT("kernel32.dll"));
+       if(attached_ok)
+       {
+               // Try to attach to the parent process if it's a console, i.e. 
we're run from a DOS prompt.
 
+               typedef BOOL (WINAPI *AttachConsole_t)(DWORD dwProcessId);
+               AttachConsole_t wxDL_INIT_FUNC(pfn, AttachConsole, kernel);
+               if(pfnAttachConsole)
+               {
+                       attached_ok = pfnAttachConsole( ATTACH_PARENT_PROCESS );
+               }else
+               {
+                       attached_ok = 0;
+               }               
+       }
+
     if (attached_ok == 0) // failed attaching
     {
         // we tried to attach, but failed don't alloc a new one
------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to