1. selvam G
  2. PowerBuilder
  3. Wednesday, 17 October 2018 14:34 PM UTC

Hi Appeon Team

I am doing prototype for a client server application, calling a C++ dll  as local external functions.

Environment PB2017 R2 Win7

When I call one of the function without any parameters as given below, which returns a string works fine.

Function   String ext_get_version() &
LIBRARY "abcd.dll"                                &
ALIAS FOR "getversion;Ansi"   

But when I call another function which has parameter Const Char* as given below

Function int ext_get_schema(  REF String algorithm) &
LIBRARY "abcd.dll"                                &
ALIAS FOR "getSchemas;Ansi"

Getting an error as invalid stock pointer on return from function call.

Please let me know what is the issue here.

We do not have source code for the dll.

Any help will be much appreciated.

Thanks

Selvam

selvam G Accepted Answer Pending Moderation
  1. Thursday, 25 October 2018 14:18 PM UTC
  2. PowerBuilder
  3. # 1

I have the third function is also working, it was a mistake due to some documentation was not clear.

But I do have some other issue on another function where application crashes due to PBVM dll, I am going to create a new thread and make this as resolved.

My conclusions:

on 64 bit environment even though C++ dll is calling convention is cdecl, I am able to call three functions without any issue in Power builder 2017 with external function.

Thanks

Selvam

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 22 October 2018 20:23 PM UTC
  2. PowerBuilder
  3. # 2

Are you sure that the DLL is Ansi and not Unicode?

Comment
  1. selvam G
  2. Monday, 22 October 2018 20:38 PM UTC


I am not sure but other two functions work only when I add ANSI.

But for this function if have ANSI or not, it does not make any difference, same thing no error message, returns nothing, out parameter come up.

For const char* return type do I have to anything special to get the value in Powerbuilder?

Thanks

Selvam
  1. Helpful
  1. Roland Smith
  2. Monday, 22 October 2018 20:47 PM UTC
Ref in the external function declaration should do it.
  1. Helpful
  1. selvam G
  2. Monday, 22 October 2018 20:59 PM UTC
Yes ref will work for parameters but this one is returning char* , I cannot ref for that returning value, hence the issue.

Function string ext_calculate (REF string parm1.....)
  1. Helpful
There are no comments made yet.
selvam G Accepted Answer Pending Moderation
  1. Monday, 22 October 2018 19:47 PM UTC
  2. PowerBuilder
  3. # 3

ok quick update I have changed everything in 64 bit, application,dll. Now the problem invalid stock pointer has been resolved, Now I got two functions working fine.

Having issue with return char * for one of the function.

const char* ABC_Calculate(const char* parm1, const char* parm2,

                      const char* parm3, const char* parm4, int* (out) parm5);

In Power builder declared external function as below

Function string  ext_calculate &
(REF string parm1, string site, &
REF string parm2, &
REF string parm3,&
REF string parm4,&
REF Int errorcode) &
LIBRARY "ABCD.dll"        &
ALIAS FOR "ABC_Calculate;Ansi"   

I am not getting any error message but no return value, although I do get parm5 out value.

Any insights please.

Thanks

Selvam

 

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 17 October 2018 14:39 PM UTC
  2. PowerBuilder
  3. # 4

Go to this page:

https://www.appeon.com/support/documents/appeon_online_help/pb2017r3/powerscript_reference/ch03s04.html

Then scroll to the bottom and read the section about _stdcall.

Comment
  1. Brad Mettee
  2. Thursday, 18 October 2018 13:21 PM UTC
Did you try using a LONG for the return type of ext_get_schema?
  1. Helpful
  1. selvam G
  2. Thursday, 18 October 2018 15:23 PM UTC
Hi

I got a dll written in Visuall C++ including _stdcall. for a simple function just to try it out

But somehow PB comes up with error opening DLL.Do I need to do any config.



Any help will be much appreciated.

Thanks

Selvam



  1. Helpful
  1. selvam G
  2. Thursday, 18 October 2018 17:34 PM UTC
Sorry when I changed return as Long instead of INT, I am getting the same nvalid stock pointer.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.