#include <stdio.h>
#include <windows.h>
static gpointer
_g_module_open (const gchar *file_name,
gboolean bind_lazy)
{
HINSTANCE handle;
handle = LoadLibrary (file_name);
if (!handle)
{
gchar error[100];
sprintf (error, "Error code %d", GetLastError ());
g_module_set_error (error);
}
return handle;
}
static gpointer
_g_module_self (void)
{
HMODULE handle;
handle = GetModuleHandle (NULL);
if (!handle)
{
gchar error[100];
sprintf (error, "Error code %d", GetLastError ());
g_module_set_error (error);
}
return handle;
}
static void
_g_module_close (gpointer handle,
gboolean is_unref)
{
if (!FreeLibrary (handle))
{
gchar error[100];
sprintf (error, "Error code %d", GetLastError ());
g_module_set_error (error);
}
}
static gpointer
_g_module_symbol (gpointer handle,
const gchar *symbol_name)
{
gpointer p;
p = GetProcAddress (handle, symbol_name);
if (!p)
{
gchar error[100];
sprintf (error, "Error code %d", GetLastError ());
g_module_set_error (error);
}
return p;
}
static gchar*
_g_module_build_path (const gchar *directory,
const gchar *module_name)
{
gint k;
k = strlen (module_name);
if (directory && *directory)
if (k > 4 && g_strcasecmp (module_name + k - 4, ".dll") == 0)
return g_strconcat (directory, "\\", module_name, NULL);
else
return g_strconcat (directory, "\\", module_name, ".dll", NULL);
else if (k > 4 && g_strcasecmp (module_name + k - 4, ".dll") == 0)
return g_strdup (module_name);
else
return g_strconcat (module_name, ".dll", NULL);
}