Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VC++ COM
Message
From
26/09/1999 22:52:07
 
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Title:
Miscellaneous
Thread ID:
00269140
Message ID:
00269182
Views:
22
>1) Is it possible to set breakpoints in the VC debugger and have them triggered when VFP calls the method? I can attach VFP as a process in the VC debugger but the breakpoints don't trigger. I know this works great if the VC component is a plain API DLL but it looks like a COM DLL works differently.

I would say that this works if you restart VFP after you've set the breakpoints and set VFP as the executable for debug session (go to Project/Settings, choose the Debug tab). The debug will not be triggered if VFP is already started.

>2) How can I clear the DLL from memory? Once VFP instantiates the COM VC can not rebuild the DLL until I completely shutdown VFP.

Are you sure all references to your object are broken? If yes and VFP still doesn't free the dll... there's not much you can do.

>3) The COM methods are returning HRESULT values and VFP is for some reason converting them to empty strings:
>
>lnResult = ox.Method()
>? type( "lnResult" ) && "C" and not N

That's probably because the methods declare return values. In this case, languages as VB or VFP will return the declared return value (which is actually a special parameter in the idl declaration) instead of the hresult value.

>4) How can I declare the COM method to take a BSTR string argument by reference so it can be an OUT or INOUT parameter. Just declaring the argument as BSTR doesn't let the method alter a variable passed by reference from VFP.

Input parameter:
IDL: MyFunction([in]BSTR tstrAString)
C++: MyFunction(BSTR tstrAString)

Output parameter:
IDL: MyFunction([out]BSTR* tstrAString)
C++: MyFunction(BSTR* tstrAString)

Return value parameter:
IDL: MyFunction([out, retval]BSTR* tstrAString)
C++: MyFunction(BSTR* tstrAString)

All output params (return values or not) must be declared as pointers. Otherwise, the value cannot be returned to the caller.

In the particular case of BSTR, if it's an input param, the caller allocates the memory space. If it's an output param (return values too), the COM object allocates the memory.

If you use CString:
*tstrAString = MyLocalCString.AllocSysString();

If you use _bstr_t:
*tstrAString = MyLocal_bstr_t.copy();

Here are some simple&quick&useful conversions:
_bstr_t Abstrt;
BSTR ABSTR;
CString ACString;

Abstrt = _bstr_t(ABSTR);
Abstrt = (LPCTSTR)ACString;
ACString = (LPCTSTR)Abstrt;
ACString = (LPCTSTR)_bstr_t(ABSTR);

BSTR is, in fact, a pointer. So, when you return a BSTR, you return, in fact, a pointer. This is why you have to change the value of the BSTR param (*tstrAString). And this is why you have to declare it as pointer to BSTR (BSTR*).

HTH,
Vlad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform