Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

COM interfaces

jjgermis
Beginner
404 Views

This topic relates to the Microsoft Component Object Model: I used the Fortran Module Wizard in VS2005 to generatea module for the COM interfaces. The COM object is created successfully. Here is the code:

[cpp]	  CALL COMINITIALIZE(status)
	  write(*,*) 'Opens the Maxwell script interface'
	  CALL COMCREATEOBJECT ("AnsoftMaxwell.MaxwellScriptInterface", maxwellapp, status)
	  write(*,*) 'Perform some FEA calculations'
	  desktop = IMaxwellAppComInterface_GetAppDesktop(maxwellapp, pVal)[/cpp]

When I try to get the desktop information, I get the following error: Unhandled exception at 0x00000000 in maxwell.exe: 0xC0000005: Access violation reading location 0x00000000.
The automatically generated COM module for the GetAppDesk functionis as follows:

[cpp]		INTERFACE
			!method GetAppDesktop
  			INTEGER(4) FUNCTION IMaxwellAppComInterface_GetAppDesktop($OBJECT, pVal)
				INTEGER(INT_PTR_KIND()), INTENT(IN)	:: $OBJECT	 ! Object Pointer
				!DEC$ ATTRIBUTES VALUE	:: $OBJECT
				INTEGER(INT_PTR_KIND()), INTENT(OUT)	:: pVal	! IDispatch
				!DEC$ ATTRIBUTES REFERENCE	:: pVal
			!DEC$ ATTRIBUTES STDCALL :: IMaxwellAppComInterface_GetAppDesktop
			END FUNCTION IMaxwellAppComInterface_GetAppDesktop
		END INTERFACE
INTEGER(4) FUNCTION $IMaxwellAppComInterface_GetAppDesktop($OBJECT, pVal) IMPLICIT NONE INTEGER(INT_PTR_KIND()), INTENT(IN) :: $OBJECT ! Object Pointer !DEC$ ATTRIBUTES VALUE :: $OBJECT INTEGER(INT_PTR_KIND()), INTENT(OUT) :: pVal ! IDispatch !DEC$ ATTRIBUTES REFERENCE :: pVal INTEGER(4) $RETURN INTEGER(INT_PTR_KIND()) $VTBL ! Interface Function Table POINTER($VPTR, $VTBL) $VPTR = $OBJECT ! Interface Function Table $VPTR = $VTBL + 28 ! Add routine table offset IMaxwellAppComInterface_GetAppDesktop_PTR = $VTBL $RETURN = IMaxwellAppComInterface_GetAppDesktop($OBJECT, pVal) $IMaxwellAppComInterface_GetAppDesktop = $RETURN END FUNCTION $IMaxwellAppComInterface_GetAppDesktop
[/cpp]

I have no experience with COM and do not know where to find information or help on this topic. I will glad for advice on how to solve this issue.

0 Kudos
0 Replies
Reply