1. Steven Sheridan
  2. PowerBuilder
  3. Friday, 1 July 2022 17:11 PM UTC

 

Recently we upgraded to Powerbuilder 2019 R3 version from an older SAP-supported PB.   We have found an issue with the external call function which looks like is now cutting off the first 2 characters we get back from it. 

We make a call to a C++ Dll cal example -> function long fc_findfirst(string filespec,  REF str_finddata fileinfo) LIBRARY "PB2CShared.dll" alias for "fc_findfirst;Ansi"

When we get back the fileinfo it is cutting off the first 2 characters of the file name.  This is creating issues in our PB program. 

Using the same C++ DLL with the older PB works fine.  The structure of the code did not change on PB or the C++ side. The only change for this call was upgrading powerbuilder. 

 

I am not sure how to fix this issue? Does the new PB support a different way to compile the code to make this work or setting? 

 

the application is build with the pcode just like the older version of PB. it is a 32 bit application just like the older version of PB. 

Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 1 July 2022 17:28 PM UTC
  2. PowerBuilder
  3. # 1

Hi,

I think you might have to use some ".....pragma pack setting ..." somewhere having to do with how many bits are being used for external functions.

I'm sorry, but I cannot access powerbuilder right now. I'll get back on this later on ...

regards.

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Friday, 1 July 2022 17:45 PM UTC
  2. PowerBuilder
  3. # 2

I think Miguel may be correct. If this external DLL uses ANSI strings, it is likely pretty old and may not use the same structure memory-packing/layout schema that is prevalent today. Can you post the exported source of the structure?

You can try including PROGMA_PACK(1) [not "pragma"] after the Alias For clause in the external function declaration and see if that helps. This tells PB to use 1-byte packing alignment for structure members instead of the default so-called 8-byte alignment.

What does the function in the external DLL do? There may be a WinAPI function that accomplishes the same or similar functionality?

Regards, John

Comment
There are no comments made yet.
Steven Sheridan Accepted Answer Pending Moderation
  1. Friday, 1 July 2022 18:33 PM UTC
  2. PowerBuilder
  3. # 3

So i think the  PROGMA_PACK(1) solved it. i found a setting on the IDE that I can set back to 1 and it looks like it fixed the external calls. 

Comment
  1. Chris Pollach @Appeon
  2. Saturday, 2 July 2022 02:13 AM UTC
Agreed Miguel ... and better yet, all ANSI SDK calls should be converted to proper UNICODE based calls.
  1. Helpful 1
  1. Miguel Leeuwe
  2. Saturday, 2 July 2022 02:18 AM UTC
So true Chris!
  1. Helpful
  1. Miguel Leeuwe
  2. Saturday, 2 July 2022 02:20 AM UTC
The problem here is that the DLL in question is old and there might not be a more recent version to use Unicode. Probably using Roland's filesys object would be the best solution if that offers the needed functionality.

regards.
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Friday, 1 July 2022 18:36 PM UTC
  2. PowerBuilder
  3. # 4

If the DLL is doing what I suspect (using Windows API functions to get a list of files), it can be done directly from PowerBuilder.

https://www.topwizprogramming.com/freecode_filesys.html

 

Comment
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.