Bill Daly on Fri, 13 Nov 1998 12:22:33 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: DOS + pari-2.0.12.alpha


Karim BELABAS wrote:
><snip>... 
> 
> P.S2: If somebody if proficient with OS/2 or Windows DLL loading, it
> shouldn't be too hard to port the install() functions to those systems (I
> don't know the equivalent of dlopen()/ dlsym() system calls though I'm sure
> they exist). This would remove the last "trivial" difference with the Unix
> version (the last non-trivial one being graphics...).

For 32-bit Windows (i.e. conditioned by #ifdef _WIN32), the functions
you are looking for are the following. These are defined in windows.h,
which you should include to get the correct prototypes.

// load the DLL file 'dllfile' and return a handle to it
HMODULE hdll;	// HMODULE is actually a void*
hdll = LoadLibrary(dllname);	// dllname can be any char*

// find the address of the function 'funcname' in the library whose
handle is 'hdll'
FARPROC procaddr;	// FARPROC is typedef'ed as int (FAR WINAPI
*FARPROC)() [see below]
procaddr = GetProcAddress(hdll, funcname);	// funcname can be any char*

You will have to typecast the procaddr to something like void*
(*proc)(), because WINAPI maps to __stdcall, which specifies a calling
sequence different from cdecl. (In particular, __stdcall functions pop
their argument lists within the called function, rather than in the
calling function.)


Regards,

Bill