cancel
Showing results for 
Search instead for 
Did you mean: 

Error 15 on External Function Call

Former Member
0 Kudos

Hello,

I have an DLL external function written in C++ compiled with Unicode.  I am receiving an error on the function call through PB.....Error number: 15;  Error calling external function %s  at line 86....  Does Unicode require that the function call be declared differently?  The declaration is below.

public SUBROUTINE  XY_abcLink (long handle, ref string parameters, ref string result) LIBRARY "XYABC.DLL" ALIAS FOR "XY_abcLink;ansi"

The DLL exists, is named correctly, has no dependencies missing (ran dependencywalker and verified), removed the ansi declaration, verified the parms being passed are correct/valid, etc.

I've read some of the other threads regarding issues with DLL external function calls but have not gathered enough information to track down my issues.  Any suggestions would be appreciated.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

The second argument is not an array...just a concatenated string of data.

I did allocate memory for the result string being returned but not for the params being passed.

I have removed the ansi suffix on the call and still receive the same error.

I will have to check and see how the DLL was compiled.

Former Member
0 Kudos

For all the C .dll files I have created, I declare the functions as WINAPI which translates to _stdcall when compiled.

Former Member
0 Kudos

Did you compile you Dll with the calling Convention _stdcall :

former_member190719
Active Contributor
0 Kudos

Yes, you need to remove the ";ANSI" suffix on your call.  That's telling PB to make the call as ANSI rather than Unicode:

public SUBROUTINE  XY_abcLink (long handle, ref string parameters, ref string result) LIBRARY "XYABC.DLL" ALIAS FOR "XY_abcLink"

CobyKako
Advisor
Advisor
0 Kudos

Hi Julie,

It would be interesting to post the PowerScript when error happens.

By the way, is the 2nd argument parameters an array of string (becasuse I see an "s" in its name)?

Also, did you use the Space() method for strings passed by reference before calling the external function?

Indeed, PB needs to allocated some spaces for strings.

HTH

Jacob