      SUBROUTINE DLLTest

      use user32
      use kernel32
      use, intrinsic :: iso_c_binding

      IMPLICIT NONE
      TYPE EigenData
c        Input data
         INTEGER  Size       
         INTEGER  ModesDim   
         INTEGER  ReqModes   
         INTEGER  Dummy      
         REAL*8   MinEV,MaxEV
         INTEGER  RetModes   
         INTEGER  ErrorCode  
      END TYPE EigenData
      TYPE (EigenData) :: pData

      ABSTRACT INTERFACE
         SUBROUTINE SGMKL(FuncID,DataPtr)

!DEC$ ATTRIBUTES STDCALL,REFERENCE :: SGMKL

            INTEGER  FuncID
            TYPE EigenData
c              Input data
               INTEGER  Size          
               INTEGER  ModesDim      
               INTEGER  ReqModes      
               INTEGER  Dummy         
               REAL*8   MinEV,MaxEV   
               INTEGER  RetModes      
               INTEGER  ErrorCode     
            END TYPE EigenData
            TYPE (EigenData) :: DataPtr
         END SUBROUTINE SGMKL
      END INTERFACE
      PROCEDURE(SGMKL), POINTER :: pMKL

      INTEGER (HANDLE)  hHandle
      INTEGER (INT_PTR) pProc
      INTEGER (BOOL)    bFree

      pData.Size=3
      pData.ModesDim=10
      pData.ReqModes=3
      pData.Dummy=0
      pData.MinEV=-10.0d0
      pData.MaxEV=50.0d0
      pData.RetModes=0
      pData.ErrorCode=0

      hHandle = LoadLibrary("SGMKL32.DLL"C)
      IF (hHandle.EQ.0) THEN
         CALL MSGBOX('Could not load SGMKL.DLL','E')
      ELSE
         pProc = GetProcAddress(hHandle,"SGMKL"C)
         IF (pProc.EQ.0) THEN
            CALL MSGBOX('Could not find MKL function in SGMKL.DLL','E')
         ELSE
            CALL C_F_PROCPOINTER(TRANSFER(pPROC,C_NULL_FUNPTR),pMKL)
            CALL pMKL(1,pData)
         ENDIF
         bFree = FreeLibrary(hHandle)
      ENDIF

      RETURN
      END
