1 /* GMODULE - GLIB wrapper code for dynamic module loading
2 * Copyright (C) 1998 Tim Janik
3 * Copyright (C) 1998 Tor Lillqvist
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * Modified by the GLib Team and others 1997-1999. See the AUTHORS
23 * file for a list of people on the GLib Team. See the ChangeLog
24 * files for a list of changes. These files are distributed with
25 * GLib at ftp://ftp.gtk.org/pub/gtk/.
35 /* --- functions --- */
37 _g_module_open (const gchar *file_name,
42 handle = LoadLibrary (file_name);
46 sprintf (error, "Error code %d", GetLastError ());
47 g_module_set_error (error);
58 handle = GetModuleHandle (NULL);
62 sprintf (error, "Error code %d", GetLastError ());
63 g_module_set_error (error);
70 _g_module_close (gpointer handle,
73 if (!FreeLibrary (handle))
76 sprintf (error, "Error code %d", GetLastError ());
77 g_module_set_error (error);
82 _g_module_symbol (gpointer handle,
83 const gchar *symbol_name)
87 p = GetProcAddress (handle, symbol_name);
91 sprintf (error, "Error code %d", GetLastError ());
92 g_module_set_error (error);
98 _g_module_build_path (const gchar *directory,
99 const gchar *module_name)
103 k = strlen (module_name);
104 if (directory && *directory)
105 if (k > 4 && g_strcasecmp (module_name + k - 4, ".dll") == 0)
106 return g_strconcat (directory, "\\", module_name, NULL);
108 return g_strconcat (directory, "\\", module_name, ".dll", NULL);
109 else if (k > 4 && g_strcasecmp (module_name + k - 4, ".dll") == 0)
110 return g_strdup (module_name);
112 return g_strconcat (module_name, ".dll", NULL);