!
!  @GLOBAL.SOURCE@ - This file contains the global data and functions
!  for the COM Server
!
!  Generated by the Intel(R) Visual Fortran COM Server Wizard on
!  @GLOBAL.DATE@ at @GLOBAL.TIME@.
!
!   DO NOT EDIT THIS FILE!
!
!  This file is re-generated every time the object hierarchy is changed.
!

!
!  M O D U L E S
!

!  Module containg DLL global data

module @GLOBAL.NAME@_Global
    use ifwinty
    use kernel32
    use IClassFactory_Types

    integer(HANDLE) ghinst
@#IFTRUE EXESERVER
@#ELSE
    integer         gCntLock
@#ENDIF
    type (T_RTL_CRITICAL_SECTION) gGlobalCriticalSection
    !  Per Class
   	@#PER CLASS
    integer(int_ptr_kind()) g@CLASS.NAME@IClassFactory
    type (IClassFactory_Data), pointer :: gp@CLASS.NAME@CFData
    integer(int_ptr_kind()) g@CLASS.NAME@ITypeInfo
    @#ENDPER

    ! Type Library GUID		
    type (guid), parameter :: GUID_TypeLib_@GLOBAL.NAME@ = &
        @(= TypeGUID(GLOBAL.TYPELIB_ID)@)

  contains

    integer function ServerLock ()
@#IFTRUE EXESERVER
        use ole32
@#ENDIF
        integer(LONG) r
@#IFTRUE EXESERVER
        r = CoAddRefServerProcess()
        ServerLock = r
@#ELSE
        r = InterlockedIncrement (loc(gCntLock)) 
        ServerLock = gCntLock
@#ENDIF
    end function

    integer function ServerUnlock ()
@#IFTRUE EXESERVER
        use ole32
        use user32
@#ENDIF
        integer(LONG) r
@#IFTRUE EXESERVER
        r = CoReleaseServerProcess()
        if (r == 0) then
            call PostQuitMessage(0)
        end if
        ServerUnlock = r
@#ELSE
        r = InterlockedDecrement (loc(gCntLock)) 
        ServerUnlock = gCntLock
@#ENDIF
    end function

end module @GLOBAL.NAME@_Global

