PROGRAM FuncPtrQn

	IMPLICIT NONE
INTERFACE 
	REAL FUNCTION LSEFUNC1(VALUES, ERRORNO, ERRORMSG)
	!DEC$ ATTRIBUTES DLLEXPORT :: LSEFUNC1
	REAL, INTENT(IN), DIMENSION(*) :: VALUES
	INTEGER, INTENT(INOUT) :: ERRORNO
	CHARACTER(256), INTENT(INOUT) :: ERRORMSG
	END FUNCTION

	REAL FUNCTION LSEFUNC2(VALUES, ERRORNO, ERRORMSG)
	!DEC$ ATTRIBUTES DLLEXPORT :: LSEFUNC2
	REAL, INTENT(IN), DIMENSION(*) :: VALUES
	INTEGER, INTENT(INOUT) :: ERRORNO
	CHARACTER(256), INTENT(INOUT) :: ERRORMSG
	END FUNCTION

	!	... carry on repeating for each possible function ?
END INTERFACE

	CALL Test1

CONTAINS

SUBROUTINE Test1
	USE KERNEL32
	CHARACTER(*), PARAMETER :: DLLPATH = &
			"d:\work\FORTRANSource\LSELIBDLL1\Debug\LSELIBDLL1.dll"
	CHARACTER(*), PARAMETER, DIMENSION(2) :: FUNCNAMES = &
			(/'LSEOvertop','LSEUplift'/)
	!	I can declare my function names in an array 
	!	which can be extended easily
	REAL, DIMENSION(2) :: PARAMS

	INTEGER HLIB
	POINTER(PFUNC1,LSEFUNC1)
	POINTER(PFUNC2,LSEFUNC2)
	!	I need separate pointers for each function (understandably)
	!	but it seems as though I'm forced to have a separate
	!	interface for each function even though
	!	the interfaces are identical (apart from the name)

	INTEGER ERRNO
	CHARACTER(256) ERRMSG
	REAL RESULT1,RESULT2

	HLIB=LoadLibrary(TRIM(DLLPATH)//CHAR(0))
	PFUNC1=GetProcAddress(HLIB,TRIM(FUNCNAMES(1))//CHAR(0))
	PFUNC2=GetProcAddress(HLIB,TRIM(FUNCNAMES(2))//CHAR(0))

	ERRNO=0
	ERRMSG=''
	RESULT1=LSEFUNC1(PARAMS,ERRNO,ERRMSG)
	RESULT2=LSEFUNC2(PARAMS,ERRNO,ERRMSG)


END SUBROUTINE

END PROGRAM FuncPtrQn

