Skip to Content
0

Using WINAPI Internet Create URL with Powerbuilder 12.6 PL13 / Build 4139

Jul 07, 2017 at 03:52 PM

211

avatar image

Hello There, in Addition to the closed blog:

https://archive.sap.com/discussions/message/15734186?tstart=0#15734186

I try to create a 64 Bit Application with PowerBuilder 12.6 (PL13 Build 4139) to use the main feature of the SAP release. I run in trouble with the Internet/URL Functions which uses the URL_COMPONENT structure.

While all the InternetCreateUrl / InternetCrackUrl etc. work in 32 Bit / none work in 64 Bit.

We always get LastError= 87 / wrong parameter.

Please Note that the structure Member nport is in c++ WORD and 2Byte but instead of UnsignedInteger we had to use in PB UnsignedLong to get the API call work, because the Alignment / Padding in the WINAPI seems to be 4Byte.

I assume that in 64Bit strings are pointers, but using 8 Byte (64 Bit) instead of 4 Byte (32 Bit).

So I tried multiple versions (see VBA 64Bit Problem https://stackoverflow.com/questions/17156699/how-to-make-winhttpcrackurl-work-in-64-bit)

So I suggest to use the progma_pack(8) statement to get the 32Bit Function working in 64 Bit

At least I end up in Prog see Zip with all variants to find the error.

Sorry, it is not permitted to upload Zips here.....

Function Boolean InternetCreateUrl32(STR_URL_COMPONENTS_32 lpUrlComponents,ULong dwFlags, ref String lpszUrl, ref uLong lpdwUrlLength) ALIAS FOR InternetCreateUrlWLibrary "wininet.dll"

Function Boolean InternetCreateUrl32_P1(STR_URL_COMPONENTS_32 lpUrlComponents, ULong dwFlags, ref String lpszUrl, ref uLong lpdwUrlLength) ALIAS FOR InternetCreateUrlWLibrary "wininet.dll"progma_pack(1)

Function Boolean InternetCreateUrl32_P8(STR_URL_COMPONENTS_32 lpUrlComponents, ULong dwFlags, ref String lpszUrl, ref uLong lpdwUrlLength) ALIAS FOR InternetCreateUrlWLibrary "wininet.dll"c

Function Boolean InternetCreateUrl64(STR_URL_COMPONENTS_64 lpUrlComponents, ULong dwFlags, ref String lpszUrl, ref uLong lpdwUrlLength) ALIAS FOR InternetCreateUrlWLibrary "wininet.dll"

Function Boolean InternetCreateUrl64_P1(STR_URL_COMPONENTS_64 lpUrlComponents, ULong dwFlags, ref String lpszUrl, ref uLong lpdwUrlLength) ALIAS FOR InternetCreateUrlWLibrary "wininet.dll"progma_pack(1)

Function Boolean InternetCreateUrl64_P8(STR_URL_COMPONENTS_64 lpUrlComponents, ULong dwFlags, ref String lpszUrl, ref uLong lpdwUrlLength) ALIAS FOR InternetCreateUrlWLibrary "wininet.dll"progma_pack(8)

global type str_url_components_32 from structure

unsignedlongdwstructsizedescriptor "comment" = "Vergleiche http://msdn.microsoft.com/en-us/library/windows/desktop/aa385420(v=vs.85).aspx"

stringlpszscheme

unsignedlongdwschemelength

unsignedlongnscheme

stringlpszhostname

unsignedlongdwhostnamelength

unsignedlongnport

stringlpszusername

unsignedlongdwusernamelength

stringlpszpassword

unsignedlongdwpasswordlength

stringlpszurlpath

unsignedlongdwurlpathlength

stringlpszextrainfo

unsignedlongdwextrainfolength

end type

global type str_url_components_64_padding120 from structure

unsignedlongdwstructsizedescriptor "comment" = "Vergleiche http://msdn.microsoft.com/en-us/library/windows/desktop/aa385420(v=vs.85).aspx"

unsignedlongpadding1descriptor "comment" = "https://msdn.microsoft.com/en-us/library/aa296569(v=vs.60).aspx"

stringlpszschemedescriptor "comment" = "4-Byte Aligmnent with 32 Bit / 8-Byte with 64 Bit so we need dummy unsignedlong var (Padding_XXX) or LongLong "

unsignedlongdwschemelengthdescriptor

unsignedlongpadding2

unsignedlongnscheme

unsignedlongpadding3

stringlpszhostname

unsignedlongdwhostnamelength

unsignedlongpadding4

unsignedlongnport

unsignedlongpadding5

stringlpszusername

unsignedlongdwusernamelength

unsignedlongpadding6

stringlpszpassword

unsignedlongdwpasswordlength

unsignedlongpadding7

stringlpszurlpath

unsignedlongdwurlpathlength

unsignedlongpadding8

stringlpszextrainfo

unsignedlongdwextrainfolength

unsignedlongpadding9

end type

// size of URL_COMPONENT structure

constant ULongURL_COMP_SIZE_32 = 60 // 15 * 4

constant ULongURL_COMP_SIZE_64 = 120// 15 * 8

astr_url.dwStructSize = in_size.sizeOf(astr_url)

In 64 Bit is URL_COMP_SIZE_32 =84 and URL_COMP_SIZE_64 =120

Any other Idea’s?

Regard’s Marco

url-component.jpg (82.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

avatar image
Former Member Jul 24, 2017 at 04:26 PM
0

For 12.6 SAP changed the byte alignment from 1 to 8 and didn't mention it in any documentation. Below is from a post in this forum:

Customers can switch to the old behavior in two ways with PB 12.6 build 4058 and above.

1. Check "Use 1-byte structure member alignment in external function" in Tools, System Options, General page (or set UseZp1=1 in [pb] section, pb.ini, the results are same). The effect is global with this setting changed. To make this work at runtime, please remember to deploy your pb.ini file with your application.

2. Add “progma_pack(1)” external function’s declaration, like this.

FUNCTION int STLAREGIO ( ref struc_kfzrechnerneu struc_kfz ) LIBRARY "KFZ_SS.DLL" alias for "STLAREGIO;Ansi" progma_pack(1)

progma_pack(1) is 1-byte align, progma_pack(8) is 8-bytes align. In this way, the effect is only for external function that is declared with this alignment.

Share
10 |10000 characters needed characters left characters exceeded
Marco Sensken Jul 26, 2017 at 08:52 AM
0

Hello Roland,

Thank you for your hint, I’m aware of the changes regarding the byte alignment found in the related posting.
I tried multiple definitions to check. While InternetCreateUrl32 / InternetCreateUrl32_P1 work with 32Bit they did not work with 64Bit.
At least InternetCreateUrl32_P1 should work with 64Bit because it has been defined with progma_pack(1).
I could try if the global option / PB.INI changes change the behavior. I have rewritten the URL Creation/Parameter splitting in PB to solve this Problem for us.

<SNIP>

Function Boolean InternetCreateUrl32(STR_URL_COMPONENTS_32 lpUrlComponents,ULong dwFlags, ref String lpszUrl, ref uLong lpdwUrlLength) ALIAS FOR InternetCreateUrlWLibrary "wininet.dll"

Function Boolean InternetCreateUrl32_P1(STR_URL_COMPONENTS_32 lpUrlComponents, ULong dwFlags, ref String lpszUrl, ref uLong lpdwUrlLength) ALIAS FOR InternetCreateUrlWLibrary "wininet.dll" progma_pack(1)

Function Boolean InternetCreateUrl32_P8(STR_URL_COMPONENTS_32 lpUrlComponents, ULong dwFlags, ref String lpszUrl, ref uLong lpdwUrlLength) ALIAS FOR InternetCreateUrlWLibrary "wininet.dll" progma_pack(8)

<SNIP>

Kind regards

Marco

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jul 26, 2017 at 02:23 PM
0

I'm also having trouble with the Winsock function 'socket' which only takes three numbers, no structures. I think that SAP didn't fully test out the 64-bit implementation.

Share
10 |10000 characters needed characters left characters exceeded