You need to be logged in to view a user's profile.
  1. Kelly Wonderly
  2. PowerBuilder
  3. Thursday, 8 October 2020 17:22 PM UTC

We recently made the switch to Powerbuilder 2019 R2 and started building in 64 bit.   

We have several programs that use external fucntion calls.   These now cause the program to crash when running the exe.   The IDE works but I believe that's because it's using the 32 bit call still.   

Here is an example of one of the external calls we've setup:

Subroutine CopyMemoryIP (ref str_hostent Destination , ulong Source, long Length) Library "KERNEL32.DLL" Alias for "RtlMoveMemory;Ansi"
Subroutine CopyMemoryIP (ref blob Destination , ulong Source, long Length) Library "KERNEL32.DLL" Alias for RtlMoveMemory
Subroutine CopyMemoryIP (ref character Destination[4] , ulong Source, long Length) Library "KERNEL32.DLL" Alias for "RtlMoveMemory;Ansi"
Subroutine CopyMemoryIP (ref ulong Destination , ulong Source, long Length) Library "KERNEL32.DLL" Alias for RtlMoveMemory

Here's an example of the errors:

          Executing object function COPYMEMORYIP for class N_CST_WSOCK32, lib entry N_CST_WSOCK32

            Executing object function +CREATE for class RUNTIMEERROR, lib entry _TYPEDEF

              Executing instruction at line 11925

              Executing object function RUNTIMEERRORCREATE for class RUNTIMEERROR, lib entry _TYPEDEF

                Executing system dll function

              End class function RUNTIMEERRORCREATE for class RUNTIMEERROR, lib entry _TYPEDEF

              Executing instruction at line 11926

            End class function +CREATE for class RUNTIMEERROR, lib entry _TYPEDEF

 

Any suggestions would be greatly appreciated!  

Thank you!

John Fauss Accepted Answer Pending Moderation
  1. Thursday, 8 October 2020 17:51 PM UTC
  2. PowerBuilder
  3. # 1

Greetings, Kelly -

The WinAPI argument datatypes, structure member datatypes and structure sizes (lengths) can differ significantly in 64-bit vs. 32-bit, as you are finding out.

I suggest you examine a series of PB Tutorials titled "Interfacing PB Applications and the Windows API" here:

https://community.appeon.com/index.php/articles-blogs/tutorials-articles/2-powerbuilder

Parts 2  and 3 will be of particular interest to you.

Regards, John

Comment
  1. Kelly Wonderly
  2. Thursday, 8 October 2020 20:29 PM UTC
Thank you for the suggestion! We are taking a look now.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 8 October 2020 18:36 PM UTC
  2. PowerBuilder
  3. # 2

Hi Kelly;

  In addition to John's great comments on 64bit SDK calls ...

  The the object name "N_CST_WSOCK32" seems to indicate that you might be using Roland's TCP/IP code available from his TopWiz website. If so, you might want to contact Roland to see if he has any code updates for 64bit processing.

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

BTW: Since PB 10.0 and higher are Unicode versions, you should not be using any ANSI SDK calls in your external calls where possible. For example:

  • Subroutine CopyMemoryIP (ref str_hostent Destination , ulong Source, long Length) Library "KERNEL32.DLL" Alias for "RtlMoveMemory;Ansi"

// Should be defined as ...

  • Subroutine CopyMemoryIP ( Ref structure Destination, ulong Source, long Length ) Library  "kernel32.dll"     Alias For "RtlMoveMemory"

HTH

Regards ... Chris

Comment
  1. Roland Smith
  2. Thursday, 8 October 2020 19:50 PM UTC
My examples come with PB 10.5 and PB 12.6 versions. The 12.6 version is updated to work in 64bit mode.



I don't remember ever using that object name, it might be from the old Sybase Code Exchange.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Thursday, 8 October 2020 19:56 PM UTC
Hi Roland ... Yes, you could very well be correct!

Hmmmm .... If that is truly Kelly's case, then she should drop the old CodeXchange approach and adapt yours. ;-)
  1. Helpful
  1. Kelly Wonderly
  2. Thursday, 8 October 2020 20:30 PM UTC
Thank you both for posting. We are looking at your suggestions and at Roland's code to compare to what is in the current version we are running.
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 8 October 2020 19:55 PM UTC
  2. PowerBuilder
  3. # 3

In 64bit apps, Windows API function arguments that are pointers must be defined as longptr. The PB runtime automatically uses the correct sized variable based on the app bitness.

Comment
  1. Kelly Wonderly
  2. Thursday, 8 October 2020 20:30 PM UTC
Thank you!!
  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.