Function.invoke return code 5 (DdeConnectList)

16 views
Skip to first unread message

adrayb

unread,
Aug 11, 2014, 9:52:11 AM8/11/14
to jniwrapp...@teamdev.com
Hello - I am a licensed JNIWrapper developer and have been very happy with JNIWrapper & WinPack.

One of our customers however is having a problem that we cant reproduce, so I figured I would post it here in case you have some insight.

The specific issue is with the DDE functionality (DdeConnectList for Excel, System). Using an older (non-JNIWrapper) library the customer works perfectly fine. However when he switches to use the JNIWrapper library we are specifically seeing a return code of 5 from Function.invoke (for DdeConnectList) which is not a valid return code that I can see.

We are using JNIWrapper v3.8.4 and I see under v3.9 release notes a comment about "Fixed the issue with retrieving a last error code", so I dont know if this is relative to this or not.

Even if the error code issue is fixed however I have no idea why the function.invoke would fail under JNIWrapper but succeed under our older library - any thoughts ?

As mentioned, we are unable to reproduce, the DdeConnectList call works perfectly fine in every scenario we have tried.

Anna Dolbina

unread,
Aug 12, 2014, 5:00:32 AM8/12/14
to adrayb, jniwrapp...@teamdev.com
Hi,

Could you please verify that the last error code is checked in a proper way? To see an example how that should be done for DDE functions you may look at the ddeConnect() method of com.jniwrapper.win32.dde.DdeClientHelper class (WinPack):
private Handle ddeConnect(long idInst, String service, String topic) throws DdeException
    {
        Function function = User32.getInstance().getFunction(FUNCTION_CONNECT);

        Handle result = new Handle();
        Handle hService = DdeFunctions.createStringHandle(idInst, service);
        Handle hTopic = DdeFunctions.createStringHandle(idInst, topic);
        function.invoke(result, new UInt32(idInst), hService, hTopic, new Pointer(null, true));
        DdeFunctions.freeStringHandle(idInst, hService);
        DdeFunctions.freeStringHandle(idInst, hTopic);
        if (result.getValue() == 0)
        {
            throw new DdeException(DdeFunctions.getLastError(idInst));
        }

        return result;
    }
As you can see, return value of Function.invoke is not checked at all. If the function fails, result value is 0 and the DdeException with information about the DDE error is thrown.

It is possible that such check will also provide you with more information about the error that occurs in your customer's environment.

Sincerely,
Anna



--
You received this message because you are subscribed to the Google Groups "JNIWrapper Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jniwrapper-for...@teamdev.com.
To post to this group, send email to jniwrapp...@teamdev.com.
Visit this group at http://groups.google.com/a/teamdev.com/group/jniwrapper-forum/.
For more options, visit https://groups.google.com/a/teamdev.com/d/optout.

adrayb

unread,
Aug 12, 2014, 9:39:02 AM8/12/14
to jniwrapp...@teamdev.com, adrian....@theice.com
Anna,

Thanks for the response. Per the JNIWrapper docs -

 public long invoke(Parameter returnValue,                    Parameter[] parameters)
Returns: Last error code. NOTE: For Windows platform only. For all other platforms the result is 0.

I was/am using the direct return code since we are (and the customer is) on a Windows platform.

However I will adjust my code to retrieve the error code like you say and see if that helps.

Thanks.
Reply all
Reply to author
Forward
0 new messages