1. Henry Guo
  2. PowerBuilder
  3. Saturday, 28 September 2024 19:49 PM UTC

I migrated our client's application from PowerBuilder 2017 32-bit to PowerBuilder 2022 64-bit, the below code can successfully run in PowerBuilder 2017 32-bit and PowerBuilder 2022 32-bit, but after I migrated to PowerBuilder 2022 64-bit, it causes error when call the external function(CopyStrMemory) in the below code, what should be changed for the below code to fit for 64-bit?

Thanks for your helps!

-----------str_hostent structure declaration--------------

-----------Local External Functions declaration in uo_winsockdll user object--------------

FUNCTION long inet_addr (string cp) LIBRARY "WSOCK32.DLL" alias for "inet_addr;Ansi"
FUNCTION long gethostbyname(Ref string host) LIBRARY "WSOCK32.DLL" alias for "gethostbyname;Ansi"

SUBROUTINE CopyStrMemory(REF str_hostent l_dest, long l_source, long l_cbcopy) LIBRARY "kernel32.dll" alias for "RtlMoveMemory;Ansi"

-----------Call External Function--------------

Long addr
Long an_ip
String ls_host_name = 'test_server'

addr = uo_winsockdll.inet_addr(ls_host_name)

an_ip = uo_winsockdll.gethostbyname(ls_host_name)

uo_winsockdll.CopyStrMemory(lstr_hostent, an_ip, 24)

-----------When call the above CopyStrMemory external function in 64bit PowerBuilder application, got the below error--------------

John Fauss Accepted Answer Pending Moderation
  1. Saturday, 28 September 2024 23:15 PM UTC
  2. PowerBuilder
  3. # 1

Hi, Henry -

In addition to the great advice Armeen has given you, I have some additional info.

It would appear that your app is using Winsock sockets. I suggest you download and carefully examine the Winsock free code sample at Roland Smith's TopWizProgramming web site:

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

All of Roland's examples have been written to work in both 32-bit and 64-bit, so you can learn a lot from them.

Please be aware that structure sizes may increase in 64-bit, due to three factors: (1). Some structure members, such as Windows handles and pointers (memory address) increase from four bytes to eight bytes. (2) Internal padding between members may increase as a result of (1). (3) Structure length in a 64-bit app must be an event multiple of eight bytes, whereas in a 32-bit app, the length has to be an even multiple of four bytes.

The migration guide contains some very good information and tips, so read through it carefully and completely.

There is also a four-part series of PowerBuilder Tech Articles on how to interface PB applications with the Windows API, which also contains information you may find helpful as you migrate your app to 64-bit. Here is a link to the first article in the series:

    https://community.appeon.com/index.php/articles-blogs/tutorials-articles/2-powerbuilder/302-interfacing-pb-applications-with-the-windows-api-part-1

Best regards, John

Comment
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Saturday, 28 September 2024 20:14 PM UTC
  2. PowerBuilder
  3. # 2

When switching from 32-bit to 64-bit you need to modify your code to be compatible... for example changing data types, windows API calls, etc.  I recommend you carefully go through the 64-bit migration guide to have good understanding what is required to migrate successfully: https://docs.appeon.com/pb2022r3/migrating_32bit_applications_to_64bit/index.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.