Basically, I get this error when I try to call a function inside upnp.dll using VB6, where upnp.dll returns a data type that is not supported by VB6. Previously, this error occurred, but with a different function / variable, and the resolution was to open upnp.dll in oleview.exe (to view information about the type library) and replace all occurrences of "Unsigned Long" with only "Long", and then compile the new TypeLib with the removed keywords "Unsigned", this solved the problem for this senario.
Now I need to solve the same problem, but for a different function / variable, but the problem is that I do not know which variable data type I need to change or delete when I am in the TypeLib view for uplp.dll.
For completeness, I will tell you where this error occurs, and then I will show you the corresponding part of the oleview / TypeLib view, which is difficult for me to change. (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 computer).
I call the .InvokeAction sActionName, aryIns, aryOuts function .InvokeAction sActionName, aryIns, aryOuts , where aryIns and aryOuts are options declared as follows: Dim aryIns As Variant, aryIns As Variant - basically, I declare this at all, put any input that I need inside aryIns, and I will get aryOuts with the results of InvokeAction Call. Well, InvokeAction turns my generic Variant into a properly sized array, reflecting the number of output elements that are returned for the ActionName used.
At the point where I get the error, I use (for sActionName) "GetStatusInfo" in "WanIPConnection" under "WAN Connection Device". I do not need to define any elements for aryIns since this call does not require or does not require any input arguments, but it provides (returns) 3 elements (results) and puts them in aryOuts. So aryOuts ends up as an array with elements from index 0 to 2 (total of 3 elements) ... and when I go through this aryOuts array, elements 0 and 1 are printed and viewed fine (no problem), but on the third item ( aryOuts (2)) I get the exception above.
Basically, the first 2 arguments are just simple strings (there is no problem accessing them), but the third argument is defined by UPnP people as Unsigned 4 Byte Integer (and that is where the problem lies), VB6 cannot interpret this datatype and does not allow me to access to this element of the array (aryOuts (2)), and I couldn’t figure out which part of TypeLib I need to change, since the definition of InvokeAction aryOuts is just indicated as VARIANT * in TypeLib, and here is the corresponding TypeLib part for your view (I included the area that I understand to be relevant if you want to add add ln areas, 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 that I mentioned earlier is defined by the string [in, out] VARIANT* pvOutActionArgs in the InvokeAction (in the TypeLib above). Basically, the whole array is defined as VARIANT * (this is normal), but I had problems accessing the 3rd element (element number 2) of the pvOutActionArgs array defined above, how can I change the TypeLib around this problem?
For reference and those of interest to you, Hans Passant (@HansPassant) helped me solve a similar scenario by asking me to delete the section without signatures of text from upnp.dll TypeLib, which was opened by oleview.exe - it helped me to do this (and the rest of the steps necessary to create and compile a new TypeLib (upnp.tbl) in the following message: A function or interface that is marked as restricted, or the function uses an automation type not supported in Visual Basic