Silverfrost Forums

Welcome to our forums

Microsoft COM interfaces

16 Oct 2009 9:49 #5188

Does FTN95 support the Microsoft Component Object Model?

I have seen a very simple example of how to use the COM interface with the Intel compiler. And now of course I would like to use FTN95 as well as this will make a lot of other stuff we do a lot easier, i.e. keep our FTN95 code.

16 Oct 2009 11:10 #5190

I think you will need to be more speciific. There is some COM stuff in the library but it is very low level.

16 Oct 2009 11:21 #5191

As mentioned, the module I have is from another compiler. Here is a part of it: MODULE maxwell USE IFWINTY USE IFCOM IMPLICIT NONE

		! CLSIDs		
		TYPE (GUID), PARAMETER :: CLSID_MaxwellAppComInterface = &
			GUID(#997B84AF, #0946, #4236, &
			  CHAR('9A'X)//CHAR('32'X)//CHAR('30'X)//CHAR('37'X)// &
			  CHAR('E0'X)//CHAR('07'X)//CHAR('02'X)//CHAR('12'X))

		! IIDs		
		TYPE (GUID), PARAMETER :: IID_IMaxwellAppComInterface = &
			GUID(#35C06A88, #6BF1, #453E, &
			  CHAR('B9'X)//CHAR('AD'X)//CHAR('E0'X)//CHAR('4C'X)// &
			  CHAR('AA'X)//CHAR('7F'X)//CHAR('75'X)//CHAR('A6'X))
		TYPE (GUID), PARAMETER :: IID_IMaxwellAppComInterfaceV12 = &
			GUID(#9BF2FF5F, #22EC, #4C0F, &
			  CHAR('BD'X)//CHAR('99'X)//CHAR('DD'X)//CHAR('8E'X)// &
			  CHAR('5E'X)//CHAR('BA'X)//CHAR('2D'X)//CHAR('7B'X))

		! Interfaces
		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
		POINTER(IMaxwellAppComInterface_GetAppDesktop_PTR, IMaxwellAppComInterface_GetAppDesktop)	! routine pointer

		! Module Procedures
		CONTAINS
			!method GetAppDesktop
			!INTEGER(INT_PTR_KIND()) FUNCTION $Application_GetWorkbooks($OBJECT, $STATUS)
  			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
	END MODULE

The main code starts with something like this: ! Initialize object pointers CALL INITOBJECTS()

	  CALL COMINITIALIZE(status)
	  write(*,*) 'Opens the Maxwell script interface'
	  CALL COMCREATEOBJECT ('AnsoftMaxwell.MaxwellScriptInterface', maxwellapp, status)
 	  IF (maxwellapp == 0) THEN
		  WRITE (*, '(' Unable to create Excel object; Aborting')')
		  CALL EXIT()
	  else
	      write(*,'(' Maxwell object created')') 		  
	  END IF	  
	  write(*,*) 'Perform some FEA calculations'
	  write(*,*) maxwellapp
	  desktop = IMaxwellAppComInterface_GetAppDesktop(maxwellapp, pVal)
	  read(*,*)

I would really like to get this working as this would save a lot of time port FTN95 to something else. I would not mind to make an example available if I get it to work.

16 Oct 2009 12:05 #5192

I will have a look at this when I get time but I am not hopeful. Problem is that SCC is not geared up to communicate with the relevant libraries.

23 Oct 2009 6:48 #5239

Hi Paul,

in which module is the COM stuff you mentioned. I would like to make a few experiments. As I understood from what I found on the internet is the GUID that needs to be defined. Unfortunately the example that I have uses symbols that is not allowed in the Salford compiler. Below is how the CLSID is defined in my example.

Each COM class is identified by a CLSID, a unique 128-bit GUID, which the server must register. COM uses this CLSID, at the request of a client, to associate specific data with the DLL or EXE containing the code that implements the class, thus creating an instance of the object.

        ! CLSIDs        
        TYPE (GUID), PARAMETER :: CLSID_MaxwellAppComInterface = &
            GUID(#997B84AF, #0946, #4236, &
              CHAR('9A'X)//CHAR('32'X)//CHAR('30'X)//CHAR('37'X)// &
              CHAR('E0'X)//CHAR('07'X)//CHAR('02'X)//CHAR('12'X))
23 Oct 2009 7:21 #5240

From memory I would guess shell32.dll is an example.

23 Oct 2009 10:56 #5241

Hi Paul,

is there some example in the Salford install directory to create a shell32.dll? I could only find shellapi.ins in the install directory. Before I can do anything it is necessary to get the pointer to the object's interface. It must be something like [color=orange:3412c9d91b]c200e360-38c5-11ce-ae62-08002b2b79ef[/color:3412c9d91b]. Furthermore, it seems like the implementation depends on the compiler at hand. Thus, the get FTN95 fit for our application a small example will be helpful. On the other hand if you think it is to low level it might be advisable to keep my hands from it.

24 Oct 2009 9:18 #5243

I will be out of my office for a few days before I can get back to you.

4 Nov 2009 3:38 #5340

Hi Paul, still out of office?

20 Nov 2009 11:05 #5396

Hi Paul,

I attended the ANSYS user meeting this week. One topic that becomes popular nowadays, especially in machine design, is the use of optimisers. Finding an optimiser is not the problem. The problem is to get the software that calculates the function value to be optimised, to be seen/visible (or controlable) by the optimiser. A very popular optimiser (in Germany) is optiSLANG (http://www.dynardo.de/). Another one is from elmoCAD (http://elmocad.com/). We of course has stuff like as well. However, the software that calculates the function value has a COM (commom object model) interface.

We have both: our optimer in Fortran and our FEM software. However, I cannot communicate with the FEM software since I cannot get the communication done. Did you have some time to look into this issue? I see Jรถrg Kuthe (QT Software) next week and will ask him for some tipps as well. My problem is that I cannot find any literature/examples for FTN95. Other compilers offer some stuff. Since this is not standard it seems like it does not apply to FTN95. And sinve I have some non-standard stuff from FTN95 I cannot switch compilers in this case - yet another dead end.

20 Nov 2009 3:44 #5398

The only place in the library where I know we use a COM interface is for BROWSE_FOR_FOLDER@. This function is written in C and is fairly low level because SCC does not have the higher level functionality that you would normally use in this context. I do not think that you would be interested in this approach.

It is certainly not possible to compile this kind of code using FTN95. If you have working code for another Fortran compiler then you may be able to create a DLL using that compiler and access the DLL from FTN95 code.

20 Nov 2009 4:36 #5402

Of course, using a DLL sounds like a good solution. I got somehow stuck with the idea of doing everthing with FTN95 ๐Ÿ˜ƒ Thanks!

6 Dec 2009 9:08 #5488

Quoted from jjgermis I got somehow stuck with the idea of doing everthing with FTN95 ๐Ÿ˜ƒ To me it is distractive a bit and with time annoying to use several compilers. Plus, FTN95 is kind of addictive

Please login to reply.