[wxPython-users] application hinstance & module name
Chris Mellon
arkanes at gmail.com
Fri Nov 23 08:50:46 PST 2007
On Nov 23, 2007 10:28 AM, Enrico Bortolazzi
<enrico.bortolazzi at infinito.it> wrote:
> Hello,
> I'm developing an application on Windows that will be used by blind
> users together with a screenreader, a software that can read what's
> on video. The screenreader need to be configured and customized to
> work well and to do this I must deliver my application with a
> configuration file. The configuration file should be named after the
> name of the process module associated with the main window of the
> program. I cannot access the code for the screenreader but I'm almost
> sure that, for getting the name of the configuration file, it call
> something like:
>
> GetModuleFileNameEx(dwProcessID, (HINSTANCE)GetWindowLong(hWnd,
> GWL_HINSTANCE), szFilename))
>
> with hwnd as the main window.
> (I also used WinExplorer, a free tool with source code, that shows
> a lot of parameters about a process and its windows)
>
> With a wxPython application this name is always __core__.pyd so my
> application should be associated with a configuration file with
> __core__ as name. The problem arise if there are more than one
> application written with wxPython. The configuration file is unique
> and stored in a private directory of the screenreader! So there
> cannot be two files with the same name.
>
This is unfortunate. However, detecting a specific application is a
pretty hard problem so I'll give them something of a pass for doing it
badly.
> I also went through the wxPython source code to search where the
> hinstance for a class is set but I cannot understand it very well,
> perhaps I need to study it in depth. I only found
> src\msw\app.cpp(354): wndclass.hInstance = wxhInstance;
> but I don't understand how to change this and its effects.
>
You can't just change the hinstance. It's what ties a window with a
specific running process.
> But my question is: there's a way to change the module name? Probably
> changing the histance associated to the main window could be a
> solution, but how to do it in Python? Or other ideas?
>
If you package your application with py2exe, it's quite possible that
you'd get the name of your packaged executable. In fact, I'm quite
surprised that whatever it's doing resolves to the wxPython .pyd and
not to python.exe. Have you confirmed that a config file for
python.exe isn't picked up?
> Thank you very much,
> Enrico
More information about the wxpython-users
mailing list