Calling COM from Intel Fortran?
- by user57460
I'm trying to get COM working from my Fortran application. I do a "COMINITIALIZE" followed by a "COMCreateObjectByProgID". Both of these appear to be successful and return a status of zero. However, when I try to use the COM object, I get "Unhandled exception at 0x00000000 in FortranProg01.exe: 0xC0000005: Access violation."
I realize that this error can mean almost anything, but has anyone got some suggestions of common problems with COM that produce this problem?
Here are some more details. My program code:
program FortranProg01
use myolepg
implicit none
integer*4 comInitStatus
integer:: comCreateStatus
INTEGER(INT_PTR_KIND()) $OBJECT
INTEGER(4) funcResult
REAL(8) pkgVersion
call COMINITIALIZE(comInitStatus)
print *, comInitStatus
call COMCreateObjectByProgID('MyOlePg.MyOlePkg', $OBJECT, comCreateStatus)
print *, comCreateStatus
funcResult = IMyOlePkg_GetPackageVersion($OBJECT, pkgVersion)
print *, funcResult
call COMUNINITIALIZE()
end program FortranProg01
The wizard-generated interface code:
INTERFACE
!property PackageVersion
INTEGER(4) FUNCTION IMyOlePkg_GetPackageVersion($OBJECT, pVal)
INTEGER(INT_PTR_KIND()), INTENT(IN) :: $OBJECT ! Object Pointer
!DEC$ ATTRIBUTES VALUE :: $OBJECT
REAL(8), INTENT(OUT) :: pVal
!DEC$ ATTRIBUTES REFERENCE :: pVal
!DEC$ ATTRIBUTES STDCALL :: IMyOlePkg_GetPackageVersion
END FUNCTION IMyOlePkg_GetPackageVersion
END INTERFACE
Any help would be much appreciated!
Thanks!
Brad.