! Sample Fortran program that finds a dll library and calls
!  a routine in it.

!        use dfwin
	use kernel32
! Declare an interface block to the routine to be called.
	interface
	   subroutine rtn_suba(a, b)
	   real*8 a, b
	   end subroutine
	end interface

	real *8 arg1, arg2
        integer p  
	pointer (q,rtn_suba)
	logical status

! First, locate the dll and load it into memory
        p = loadlibrary("testsub.dll"C)
	if (p == 0) then
		type *, "Error occurred opening testsub.dll"
		type *, "Program aborting"
		goto 1000
	endif

! Set up a pointer to the routine of interest
        q = getprocaddress(p, "SUBA"C)
	if (q == 0) then
		type *, "Error occurred finding SUBA in testsub.dll"
		type *, "Program aborting"
		goto 1000
	endif

! Now, the routine can simply be called
        call rtn_suba(arg1, arg2)
	write(*,*)arg1, arg2
	status = freelibrary(p)
D	type *, "freelibrary status was: ", status
1000	continue

        end
