dynamiclibrary_windows.h File Reference

#include <Windows.h>
#include "BOOL.h"

Include dependency graph for dynamiclibrary_windows.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define IMPORT_EXPORT_DYNAMICLIBRARY_DLL   __declspec(dllimport)

Typedefs

typedef HINSTANCE DynLibHandle
typedef FARPROC DynLibFuncPtr

Functions

IMPORT_EXPORT_DYNAMICLIBRARY_DLL
DynLibHandle 
LoadDynLibrary (char *libname)
IMPORT_EXPORT_DYNAMICLIBRARY_DLL
BOOL 
FreeDynLibrary (DynLibHandle hInstance)
IMPORT_EXPORT_DYNAMICLIBRARY_DLL
DynLibFuncPtr 
GetDynLibFuncPtr (DynLibHandle hInstance, char *funcName)
IMPORT_EXPORT_DYNAMICLIBRARY_DLL
char * 
GetLastDynLibError (void)


Define Documentation

#define IMPORT_EXPORT_DYNAMICLIBRARY_DLL   __declspec(dllimport)

Definition at line 22 of file dynamiclibrary_windows.h.


Typedef Documentation

typedef FARPROC DynLibFuncPtr

Definition at line 26 of file dynamiclibrary_windows.h.

typedef HINSTANCE DynLibHandle

Definition at line 25 of file dynamiclibrary_windows.h.


Function Documentation

IMPORT_EXPORT_DYNAMICLIBRARY_DLL BOOL FreeDynLibrary ( DynLibHandle  hInstance  ) 

Decrements the reference count of the loaded dynamic-link library

Parameters:
Handle to the loaded library
Returns:
BOOL If the function succeeds, the return value is nonzero

Definition at line 21 of file dynamiclibrary_others.c.

References FALSE, NULL, and TRUE.

00022 {
00023         if (hInstance)
00024                 {
00025                         if (dlclose( hInstance)) return TRUE;
00026                 }
00027         #ifndef NDEBUG
00028         else 
00029                 {
00030                         printf("FreeDynLibrary: Cannot close a not-opened library.\n");
00031                         fflush(NULL);
00032                 }
00033         #endif
00034 
00035         return FALSE;
00036 }

IMPORT_EXPORT_DYNAMICLIBRARY_DLL DynLibFuncPtr GetDynLibFuncPtr ( DynLibHandle  hInstance,
char *  funcName 
)

Retrieves the address of an exported function

Parameters:
Handle to the loaded library
string that specifies the function
Returns:
Retrieves the address of an exported function
Parameters:
Handle to the loaded library
string that specifies the function
Returns:
a pointer

Definition at line 38 of file dynamiclibrary_others.c.

References NULL.

00039 {
00040         if (hInstance)
00041         {
00042                 return dlsym(hInstance, funcName);
00043         }
00044         return NULL;
00045 }

IMPORT_EXPORT_DYNAMICLIBRARY_DLL char* GetLastDynLibError ( void   ) 

return last dynamic linking error

Returns:
a string

Definition at line 37 of file dynamiclibrary_windows.c.

References buffer, and NULL.

00038 {
00039         static char buffer[512];
00040         DWORD dw = GetLastError(); 
00041         DWORD source = 0;
00042 
00043         if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
00044                         FORMAT_MESSAGE_IGNORE_INSERTS, &source, dw, 0,
00045                         buffer, 512, NULL) == 0) 
00046         {
00047                         strcpy(buffer, "Unknown Error");
00048         }
00049 
00050         return buffer;
00051 }

IMPORT_EXPORT_DYNAMICLIBRARY_DLL DynLibHandle LoadDynLibrary ( char *  libname  ) 

Maps the specified executable module into the address space of the calling process

Parameters:
name of dynamic library
Returns:
Handle to the loaded library

Definition at line 15 of file dynamiclibrary_windows.c.

00016 {
00017         return (DynLibHandle) LoadLibrary(libname);
00018 }


Generated on Tue Sep 9 17:48:42 2008 for Scilab [trunk] by  doxygen 1.5.5