@@ -267,8 +267,6 @@ static PyMethodDef functions[] = {
267
267
#ifdef DYNAMIC_TKINTER
268
268
// Functions to fill global TCL / Tk function pointers from tkinter module.
269
269
270
- #include < dlfcn.h>
271
-
272
270
#if PY3K
273
271
#define TKINTER_PKG " tkinter"
274
272
#define TKINTER_MOD " _tkinter"
@@ -288,6 +286,29 @@ char *fname2char(PyObject *fname)
288
286
#define fname2char (s ) (PyString_AsString(s))
289
287
#endif
290
288
289
+ #if defined(_MSC_VER)
290
+ #include < windows.h>
291
+ #define LIB_PTR_TYPE HMODULE
292
+ #define LOAD_LIB (name ) LoadLibrary(name)
293
+ FARPROC_dfunc (LIB_PTR_TYPE lib_handle,const char *func_name)
294
+ {
295
+ // Load function `func_name` from `lib_handle`.
296
+ // Set Python exception if we can't find `func_name` in `lib_handle`.
297
+ // Returns function pointer or NULL if not present.
298
+
299
+ char message[100 ];
300
+
301
+ FARPROC func =GetProcAddress (lib_handle, func_name);
302
+ if (func ==NULL ) {
303
+ sprintf (message," Cannot load function %s" , func_name);
304
+ PyErr_SetString (PyExc_RuntimeError, message);
305
+ }
306
+ return func;
307
+ }
308
+ #else
309
+ #include < dlfcn.h>
310
+ #define LIB_PTR_TYPE void *
311
+ #define LOAD_LIB (name ) dlopen(name, RTLD_LAZY)
291
312
void *_dfunc (void *lib_handle,const char *func_name)
292
313
{
293
314
// Load function `func_name` from `lib_handle`.
@@ -303,8 +324,9 @@ void *_dfunc(void *lib_handle, const char *func_name)
303
324
}
304
325
return func;
305
326
}
327
+ #endif
306
328
307
- int _func_loader (void * lib)
329
+ int _func_loader (LIB_PTR_TYPE lib)
308
330
{
309
331
// Fill global function pointers from dynamic lib.
310
332
// Return 1 if any pointer is NULL, 0 otherwise.
@@ -328,7 +350,7 @@ int load_tkinter_funcs(void)
328
350
// Load tkinter global funcs from tkinter compiled module.
329
351
// Return 0 for success, non-zero for failure.
330
352
int ret = -1 ;
331
- void * tkinter_lib;
353
+ LIB_PTR_TYPE tkinter_lib;
332
354
char *tkinter_libname;
333
355
PyObject *pModule =NULL , *pSubmodule =NULL , *pString =NULL ;
334
356
@@ -348,7 +370,7 @@ int load_tkinter_funcs(void)
348
370
if (tkinter_libname ==NULL ) {
349
371
goto exit;
350
372
}
351
- tkinter_lib =dlopen (tkinter_libname, RTLD_LAZY );
373
+ tkinter_lib =LOAD_LIB (tkinter_libname);
352
374
if (tkinter_lib ==NULL ) {
353
375
PyErr_SetString (PyExc_RuntimeError,
354
376
" Cannot dlopen tkinter module file" );