Trying to invoke DLL function
Erran Berger <[email protected]>
| Newsgroups | gmane.comp.windows.devel.jawin |
|---|---|
| Message-ID | <LISTSERV%[email protected]> |
Hello,
I've been struggling with this problem all day and was hoping someone on
this list could help me. Due to my naivety in VB and how jawin works, I
imagine I've just overlooked something small and stupid, but i need help
so here goes -
I've written a VERY simple DLL in VB:
Public Function sum(i As Integer, j As Integer) As Integer
sum = i + j
End Function
I compiled the DLL and placed it in my system32 folder, and registered it
with regsvr32. I then tried to use the simple calling a DLL Entry point
invocation method as specified in the jawin introduction. That code
looked somethign like this:
FuncPtr sum = new FuncPtr("Sum.DLL", "sum");
System.out.println(sum.invoke(3,4, ReturnFlags.FAIL_ON_FALSE));
(I'm not sure yet how to get the return value of the invocation... i tried
just printing it out, but either way my code fails before then).
The result of that code was:
Loading jawin from hardcoded path c:/jawin-1.0.19/bin/debug/jawind.dll
org.jawin.COMException: 8007007f: The specified procedure could not be
found.
at org.jawin.Bootstrap.loadFunction(Native Method)
at org.jawin.FuncPtr.<init>(FuncPtr.java:29)
at dllTestMain.main(dllTestMain.java:28)
I'm not sure quite what that meant, so I tried to then use the
TypeBrowser. That produced me a class _Sum that imitated the Calling a
COM component w/stubs method of invocation. So I tried the following code:
Ole32.CoInitialize();
_Sum sum = new _Sum("");
short i[] = {3};
short j[] = {4};
System.out.println("Sum: " + sum.sum(i, j));
Ole32.CoUninitialize();
And got this result:
Loading jawin from hardcoded path c:/jawin-1.0.19/bin/debug/jawind.dll
org.jawin.COMException: 8000ffff: NULL GIT peer
at org.jawin.marshal.GenericStub.dispatchInvoke0(Native Method)
at org.jawin.marshal.GenericStub.dispatchInvoke
(GenericStub.java:84)
at org.jawin.DispatchPtr.invokeN(DispatchPtr.java:473)
at org.jawin.DispatchPtr.invokeN(DispatchPtr.java:433)
at _Sum.sum(_Sum.java:258)
at dllTestMain.main(dllTestMain.java:36)
Lastly I tried passing in the sting "new:Sum" to the _Sum constructor, but
that gave me a COMException stating: "800401f3: invalid class string".
I'm stuck. Can anyone offer some advice?