Home > database >  The following a program, PB7 in normal operation, PB12 error, look what's the problem?
The following a program, PB7 in normal operation, PB12 error, look what's the problem?

Time:09-20

Pb7:

The FUNCTION Long CreateFile (String lpFileName, Long dwDesiredAccess, Long dwShareMode, Long lpSecurityAttributes, Long dwCreationDisposition, Long dwFlagsAndAttributes, Long hTemplateFile) LIBRARY "kernel32" ALIAS FOR "CreateFileA
"The FUNCTION Long CloseHandle (Long hObject) LIBRARY "kernel32
"The FUNCTION Boolean ReadFile (long fhand, ref string lpbuffer, long numbyte, ref long bytesread, long lpover) LIBRARY "kernel32. DLL
"Long SetFilePointer (Long fhand, ulong distancetomove, ulong distincetomovehigh, ulong move) LIBRARY "kernel32. DLL
"The FUNCTION Long GetLastError () LIBRARY "kernel32. DLL
"
All variable declarations:
Ll_hDevice=CreateFile (" \ \. \ PHYSICALDRIVE3 ", & amp;
GENERIC_READ FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0)

If ll_hDevice & lt;> INVALID_HANDLE_VALUE Then
Ll_fileposition=SetFilePointer (ll_hDevice, 512 * ll_sectors, 0, FILE_Begin)

Ll_error=GetLastError ()
If ll_error & lt;> 0 Then
Messagebox (' hint ', 'SetFilePointer failed, ErrorNo:' + string (ll_error))
End the If
.
End the If
Everything is normal,

PB12:

//declare the function externally for window
The FUNCTION Long CreateFile (String lpFileName, Long dwDesiredAccess, Long dwShareMode, Long lpSecurityAttributes, Long dwCreationDisposition, Long dwFlagsAndAttributes, Long hTemplateFile) LIBRARY "kernel32" ALIAS FOR "CreateFileA; Ansi
"The FUNCTION Long CloseHandle (Long hObject) LIBRARY "kernel32
"
The FUNCTION Boolean ReadFile (long fhand, ref string lpbuffer, long numbyte, ref long bytesread, long lpover) LIBRARY "kernel32. DLL" alias for "ReadFile; Ansi
"
The FUNCTION ULong SetFilePointer (long fhand, long distancetomove, long distincetomovehigh, long move) LIBRARY "kernel32. DLL
"The FUNCTION Long GetLastError () LIBRARY "kernel32. DLL
"
Program,
In setting up a pointer, such as about 600000 sectors PB7 is normal, and in the pb reported for 12 setfilepointer error, error number 126.

A bit dizzy, don't know what's the problem? The difference of character set?

CodePudding user response:

The FUNCTION ULong SetFilePointer (long fhand, long distancetomove, long distincetomovehigh, long move) LIBRARY "kernel32. DLL" alias for "SetFilePointer; Ansi
"

CodePudding user response:

The FUNCTION Long CreateFile (String lpFileName, Long dwDesiredAccess, Long dwShareMode, Long lpSecurityAttributes, Long dwCreationDisposition, Long dwFlagsAndAttributes, Long hTemplateFile) LIBRARY "kernel32" ALIAS FOR "CreateFileW
"The FUNCTION Long CloseHandle (Long hObject) LIBRARY "kernel32
"The FUNCTION Boolean ReadFile (long fhand, ref string lpbuffer, long numbyte, ref long bytesread, long lpover) LIBRARY "kernel32. DLL" ALIAS FOR "ReadFileW
"

CodePudding user response:

As a result of the character set issues, after the PB10 statement external variables with ANSI, look at the building only one function is declared according to the agreement,

CodePudding user response:

PB10 the following version of the program, use ANSI string coding, PB10 or above, using the Unicode, so the API function definition, will be A little discrepancy. Most of the use of the string in the parameters or return values of Windows API functions, provide two versions of the API, A is the ANSI, generally add A marked A behind the function, A support Unicode, generally in the function W (WideChar) as A tag after it. Such as GetWindowTextA and GetWindowTextW, therefore, when pb9, define the API function is generally use the ANSI version (because pb9 use ANSI code), if it is to upgrade to the PB10 or later, you can define the API function to use Unicode version can, rather than using PB program directly upgrade, to continue using the ANSI version,

If the PB10 and above also need to define the Ansi version of the function, the need to define a function declaration; Ansi

Based on analysis, under the pb10 version after a API defines the following
The Function Boolean GetTextExtentPoint32A (ulong HDCR, string lpString, long nCount, ref os_size size) Library "GDI32. DLL
"The upgrade to the PB10 and above version, it can be modified
(1)
The Function Boolean GetTextExtentPoint32A (ulong HDCR, string lpString, long nCount, ref os_size size) Library "GDI32. DLL" alias for "GetTextExtentPoint32A; Ansi
"(2)
The Function Boolean GetTextExtentPoint32A (ulong HDCR, string lpString, long nCount, ref os_size size) Library "GDI32. DLL" alias for "GetTextExtentPoint32W
"(3) change the function name
The Function Boolean GetTextExtentPoint32W (ulong HDCR, string lpString, long nCount, ref os_size size) Library "GDI32. DLL
"


CodePudding user response:

Thank you for your answer to my question, but
Pb 12

The FUNCTION ULong SetFilePointer (long fhand, long distancetomove, long distincetomovehigh, long move) LIBRARY "kernel32. DLL" alias for "SetFilePointer; Ansi
"After that, the problem is still

In setting up to about 100000 sectors, OK, no problem, but if set to no. 500000 or so sector, is an error,
Read U disk, 2 g space, according to the physical device is read, strange, everybody to help me think about it,

CodePudding user response:

Finally find the question nagged me for days, estimate I also encountered the problem characters, functions defined in 8 or 9 version works, but yesterday after upgraded to 10, how don't perform, first thanks for 4th floor reply, such as work try whether can solve my problem

CodePudding user response:

Relative to character, or a new version of the application

CodePudding user response:

Four years have no PB, thought the relics in PB, unexpectedly someone USES, and the new,

CodePudding user response:

refer to the eighth floor arice_lee response:
no PB for four years, thought that PB the relics, unexpectedly someone USES, and the new,


Are you a talent

CodePudding user response:

When I was calling CreateFile success, but not ReadFile always getlasterror is 6, can you help?

CodePudding user response:

Find out why...nullnull
  • Related