1. Sathishkumar S
  2. PowerBuilder
  3. Thursday, 29 December 2022 14:10 PM UTC

Hi 

I am working migrating pb2019 to pb2022 (64 bit) whereas i am getting an error which points to the findnextfilew in the object pfc_n_cst_filesrvunicode  (sometimes it popsup the below system error sometime application crashes.) 

what may be the reason, how can I resolve this.

 

 

Thank you,

Sathishkumar.

Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Monday, 2 January 2023 14:02 PM UTC
  2. PowerBuilder
  3. # Permalink
The Microsoft documentation for the FindFirstFileW API function tells us that it returns a HANDLE datatype, which is a generic Windows O/S handle. In a 32-bit application, handles are 32-bit integers. In a 64-bit application, handles are 64-bit integers. Thus, the PB Longptr datatype is the ideal choice to use as the return type from FindFirstFileW. The LongLong datatype will work (as you have noted) in a 64-bit PB app, but it may fail when the app runs as 32-bit (for example, when the app is run from the IDE in version prior to PB 2022, or in PB 2022 when the IDE bitness selector is "x86"). I'm somewhat surprised this issue exists in the latest version of the PFC, as I was under the impression that the objects had been inspected and modified as needed to support 64-bit execution. Perhaps this one WinAPI call was missed, but there may be more that need to be serviced.
Comment
  1. Sathishkumar S
  2. Monday, 2 January 2023 14:06 PM UTC
Thank you, John Fauss, for the explanation. As you suggest, the ideal choice is longptr, it is working fine for me with pb2022 64bit.



Thank you.
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Saturday, 31 December 2022 21:40 PM UTC
  2. PowerBuilder
  3. # 1

My Filesys example has this for the functions:

Function longptr FindFirstFile ( &
	string lpFileName, &
	Ref win32_find_data lpFindFileData &
	) Library "kernel32.dll" Alias For "FindFirstFileW"

Function boolean FindNextFile ( &
	longptr hFindFile, &
	Ref win32_find_data lpFindFileData &
	) Library "kernel32.dll" Alias For "FindNextFileW"

Function boolean FindClose ( &
	longptr hFindFile &
	) Library "kernel32.dll" Alias For "FindClose"
Comment
  1. Sathishkumar S
  2. Monday, 2 January 2023 14:05 PM UTC
Thank you, Roland Smith.



I have changed the datatype in my functions from long to longptr and it is working fine.



Thank you.
  1. Helpful
There are no comments made yet.
Sathishkumar S Accepted Answer Pending Moderation
  1. Friday, 30 December 2022 15:31 PM UTC
  2. PowerBuilder
  3. # 2

HI John Fauss,



I have tried 2 ways as follows, kindly advise



1. After download the PFC 2022 i have compared the object pfc_n_cst_filesrvunocode and its not show diff other than some private and public functions i have imported the object but not resolving the issue



2. I have tried some changes on the existing object itself

From old

Function long FindFirstFileW (ref string filename, ref os_finddata findfiledata) library "KERNEL32.DLL"



to New 1

Function longptr FindFirstFileW (ref string filename, ref os_finddata findfiledata) library "KERNEL32.DLL"

to new2

Function longlong FindFirstFileW (ref string filename, ref os_finddata findfiledata) library "KERNEL32.DLL"



I have modified the datatype of the handle from long to longlong/longptr

It seems to be working fine.



Thank you.

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 29 December 2022 14:27 PM UTC
  2. PowerBuilder
  3. # 3

You are probably using an old version of the PFC/PFE pbl's that does not contain the changes needed for 64-bit. Try upgrading your version of the PFC to the latest version.

   https://github.com/OpenSourcePFCLibraries

 

Comment
  1. Sathishkumar S
  2. Thursday, 29 December 2022 14:31 PM UTC
Thank you, John Fauss,



I will use the link and get the latest version of PFC and try.



  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.