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 wizard

ferrad01
Beginner
1,022 Views

I have to create some code to interface to a COM DLL. I have used the COM wizard in Compaq, I have 2 questions:

1. Is the COM wizard available in Intel v9.1 or do I have upgrade to v10.0?

2. I have used the COM wizard to create Fortran COM DLL's, however in this case I want to writeFortran code in an EXE which can access the functions of a third party COM DLL. Can the COM wizard do this as well, or do I need something else?

ferrad

0 Kudos
7 Replies
Steven_L_Intel1
Employee
1,022 Views
The COM Wizard is not in 9.1, but it's not what you're looking for. You want the "Fortran Module Wizard" which is in 9.1.
0 Kudos
John_B__Walter
Beginner
1,022 Views

Thanks, I have an interest in this too. I used the "Fortran Module Wizard" to generate code. It includes two parameters (a CLSID and an IID for events), interface code for the sundrie events, and routines for the various methods. All well and good.

So, can I provide code for the events simply by creating routines that match the interface code, or do I need to do something with the IID provided, or something different?

Thanks,

John

0 Kudos
Steven_L_Intel1
Employee
1,022 Views
I'm not an expert in COM programming, but I think the idea here is that there are interfaces (and jacket routines) created by the module wizard for the methods in the COM DLL or TLB. You then call these routines appropriately - you don't create the routines yourself.
0 Kudos
John_B__Walter
Beginner
1,022 Views

I received an OCX file which is a COM interface for some equipment which connects via a serial port. It includes interrupts for things such as "acquisition complete" and "move complete". I also received a sample program written in Visual Basic, and that code includes event handlers which process these interrupts. I'm sure the same must be possible in the FORTRAN implementation. The "Fortran Module Wizard" produced "Interface Code" for these handlers, but since these have to be customizable (hence they are events rather than methods), I have my question about whether I write my routines to match the interfaces.

Beyond that question, once I used "COMCreateObjectByProgID" to get the IDispatch pointer for an instance of the control, whenever I try to do anything with it, such as call the method for "AboutBox", I get an HRESULT=0x8000FFFF (Catastrophic failure)? Besides calling "ComInitialize(Status)" before any other calls to the COM interface, is there something else I might need to do for the instance, say to initialize it? If I try to use an unsupported method, bypassing the device module produced by the wizard, I get HRESULT=0x80020006 (Unknown name.) instead. It is only for supported methods that I get Catastrophic failure. (whether using the ocx module or bypassing it and using the AUTO routines directly).

Thanks for trying

john

0 Kudos
John_B__Walter
Beginner
1,022 Views

This has taken awhile, but I've got the AboutBox method to work!.

I had to resort to a C++ routine to initialize my instance.

C++ routines used:

CoGetClassObject - I need multiple objects (for multiple instruments of same type) gives me an IClassFactory object

(ICF object)->CreateInstance gives me an iUnknown pointer to an uninitialized instance

(iUnknown pointer)->QueryInterface(IID_IPersistMemory,..); lets me get an IPersistMemory pointer to it

(iPersistMemory pointer)->InitNew(); initializes the instance (finally)

(iUnknown pointer)->QueryInterface(IID_IDispatch,...); gives me an IDispatch pointer that I can use to access the device.

There doesn't appear to be a FORTRAN COM/AUTOMATION routine to accomplish the initialization, nor to do the CoGetClassObject nor CreateInstance functions.

To connect my eventhandlers to the events produced by the instrument software, I will need to use the C++ intrinsic __hook function, and there appears to be no accomodation for this in the FORTRAN COM/AUTOMATION routines.

In that regard you were 100% correct Steve, I don't write routines with the _event names which the Fortran Module Wizard created interfaces for. Those routines produce the events to which I __hook my handlers.

Thanks, it was very satisfying to see that About box finally pop up.

0 Kudos
g_f_thomas
Beginner
1,022 Views

Thanks for sharing this John.

ant

It annoys me when a poster keepsa solution to themselves instead of letting others benefit from their experience. I just went through this in setting up a dual boot on Vista. A whole forum I visited spews out the same while omitting one single but critical detail.

ant

Gerry

0 Kudos
John_B__Walter
Beginner
1,022 Views

It's been a while, but I'm finally back to this project, and have deepened my understanding of COM and ActiveX.

What I was thinking of as callbacks are actually events generated by the ActiveX control.

The COM Wizard captures the calling interface for each of these events, as well as identifying the COM Interface (such as IID__events in my case), and the memberID for each such event defined in the COM Interface. These callbacks are implemented by writting a subroutine which fits the calling interface, and connects it to the ActiveX Object with something like:

CALL COMInitialize(STATUS) ! Initialize COM library

IF (.NOT. DlgInit(IDD_PIC9550fr,DLG)) THEN! FAILED to start Dialog having ActiveX Object

RETINT = MESSAGEBOXQQ( 'Unable to initlize IDD_PIC9550fr'C, &

trim(PROGNAME),MB$OK)

ELSE! initialized dialog containing my ActiveX Object

IF (DlgModeless(DLG)) THEN ! activate dialog (needed to access object)

retlog = DlgGet(DLG,IDC_ActiveX, OBJECT, DLG_IDISPATCH)! Get IDispatch for it

! NOW, connect my handler (ConnectEv) to the Object

retint = DlgSetCtrlEventHandler(DLG,IDC_ActiveX, ConnectEv, memID, IID_events)

do while (.TRUE.)

if ( PeekMessage (mesg, NULL, 0, 0, PM_REMOVE) .and. &

DlgIsDlgMessage(mesg) .EQV. .FALSE. )

then

if (mesg.message == 273) exit ! do

retlog = TranslateMessage( mesg )

retint = DispatchMessage( mesg )

end if

end do

END IF

END IF

It's in that DlgSetCtrlEventHandler that I'm currently having trouble, at least on some machines. Instead

of getting my routine connected, I get a Microsoft C++ dialog box informing me of an Assertion Failed! Program ...    File: dlglow.cpp  Line: 1189   Expression: SUCCEEDED(hr)
Does anyone have an idea as to what is up with that??
0 Kudos
Reply