Basically, I'm getting this error when I try to call a function inside the upnp.dll using VB6, where upnp.dll is returning a datatype that is not supported by VB6. Previously, this same error occured but on a different function/variable, and the resolution was to open up upnp.dll in oleview.exe (to view Type Library Information) and to replace all occurences of "Unsigned Long" with just "Long" and then compile a new TypeLib with the "Unsigned" keywords removed, this solved the problem for that senario.
Now, I need to solve the same problem but for a different function/variable, but the problem is, I have no idea which variable datatype I need to change or remove when I'm in oleview's TypeLib view of upnp.dll.
For completeness, I'll let you know where this error is occuring, and then I will show you the relevant part of the oleview/TypeLib view that I am having trouble modifying. (for your information, upnp.dll is contained in windows\system32 and oleview.exe comes with the Windows SDK Toolkit if you do not already have it on your machine).
I am calling the function .InvokeAction sActionName, aryIns, aryOuts where aryIns and aryOuts are Variants declared like this: Dim aryIns As Variant, aryIns As Variant - basically, I declare it generally, put any input data I need inside aryIns and I will get aryOuts with the results of the InvokeAction call. The good thing is, InvokeAction turns my general Variant into a properly dimensioned array reflecting the number of output items that are returned for the ActionName I'm using.
Re the point I'm getting the error, I am using (for sActionName) "GetStatusInfo" on a "WanIPConnection" under the "WAN Connection Device". I don't need to define any items for aryIns since this call doesn't require or need any input arguments, but it provided (returns) 3 items (results) and puts them in aryOuts. So aryOuts ends up as an array with items from index 0 to 2 (3 items total)... and when I loop through this aryOuts array, the items 0 and 1 are printed out and viewed perfectly (without problems) but on the 3rd item (aryOuts(2)) I get the above exception.
Basically, the first 2 arguments are just simple strings (no problem accessing these) but the 3rd argument is defined by the UPnP people as an Unsigned 4 Byte Integer (and this is where the problem lays), VB6 is unable to interpret this datatype and is not letting me access this array item (aryOuts(2)), and I could not figure out what part of the TypeLib I need to modify, since the definition for InvokeAction aryOuts is just stated as a VARIANT* in the TypeLib, and here is the relevant part of the TypeLib for your view (I've included the area I understand to be relevant, if you would like additional areas posted, let me know and I can do this):
[
odl,
uuid(A295019C-DC65-47DD-90DC-7FE918A1AB44),
helpstring("IUPnPService Interface"),
dual,
nonextensible,
oleautomation
]
interface IUPnPService : IDispatch {
[id(0x600209c5), helpstring("method QueryStateVariable")]
HRESULT QueryStateVariable(
[in] BSTR bstrVariableName,
[out, retval] VARIANT* pValue);
[id(0x600209c6), helpstring("method InvokeAction")]
HRESULT InvokeAction(
[in] BSTR bstrActionName,
[in] VARIANT vInActionArgs,
[in, out] VARIANT* pvOutActionArgs,
[out, retval] VARIANT* pvRetVal);
[id(0x600209c7), propget, helpstring("property ServiceTypeIdentifier")]
HRESULT ServiceTypeIdentifier([out, retval] BSTR* pVal);
[id(0x600209c8), helpstring("method AddStateChangeCallback")]
HRESULT AddCallback([in] IUnknown* pUnkCallback);
[id(0x600209c9), propget, helpstring("property Id")]
HRESULT Id([out, retval] BSTR* pbstrId);
[id(0x600209ca), propget, helpstring("property LastTransportStatus")]
HRESULT LastTransportStatus([out, retval] long* plValue);
};
The aryOuts() array I was talking about before is defined by the [in, out] VARIANT* pvOutActionArgs line in the InvokeAction declaration (in the TypeLib above). Basically, the whole array is defined as a VARIANT* (which is fine) but I am having trouble accessing the 3rd element (index item number 2) of the pvOutActionArgs array defined above, how do I modify the TypeLib around this problem?
For reference, and those of you that are interested, Hans Passant (@HansPassant) helped me in solving the similar scenario by asking me to remove the Unsigned section of Text from the upnp.dll TypeLib exposed by oleview.exe - he helped me do this (and the rest of the steps necessary to produce and compile the new TypeLib (upnp.tbl) in the following post: Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic
aryOuts(2)to aLongvariable (lStatusBits = aryOuts(2)). There should be no problem accesing aVT_UI4variants in VB6, unless it's choking onFor Each vElem ...loops (vElembeing a variant) or variant to variant assignment. There is nothing you can do in your typelib to workaround this behavior. If nothing else works you can change variant type manually with something likeCall CopyMemory(aryOuts(2), VT_I4, 2)whereVT_I4 = 3- wqw