Using Win32 functions in Visual FoxPro Image Gallery
File Management
..msdn
CopyFile
CopyFileTransacted
CreateDirectory
CreateFile
CreateFileTransacted
CreateHardLink
CreateSymbolicLink
DeleteFile
DeleteFileTransacted
FindClose
FindCloseChangeNotification
FindFirstChangeNotification
FindFirstFile
FindNextChangeNotification
FindNextFile
FlushFileBuffers
GetBinaryType
GetCurrentDirectory
GetDriveType
GetFileAttributes
GetFileAttributesEx
GetFileInformationByHandle
GetFileType
GetFullPathName
GetLongPathName
GetShortPathName
GetTempFileName
GetTempPath
LockFile
MoveFile
MoveFileTransacted
OpenFile
QueryDosDevice
ReadDirectoryChangesW
ReadFile
RemoveDirectory
RemoveDirectoryTransacted
ReplaceFile
SearchPath
SetCurrentDirectory
SetEndOfFile
SetFileAttributes
SetFilePointer
SetFilePointerEx
SetSearchPathMode
UnlockFile
WriteFile
_lclose
_lopen
Code examples:
SetEndOfFile
..msdn    Add comment     W32 Constants      Translate this page
Sets the physical file size for the specified file to the current position of the file pointer.
Code examples:
Declaration:
BOOL WINAPI SetEndOfFile(
  __in  HANDLE hFile
);
FoxPro declaration:
DECLARE INTEGER SetEndOfFile IN kernel32;
    INTEGER hFile
Parameters:
hFile [in]
A handle to the file to be extended or truncated.
Return value:
If the function succeeds, the return value is nonzero.
Usage:
cSrc = "c:\temp\test123.txt"

* do not get confused with the function name;
* in this configuration it does not create
* but opens an existing file
hFile = CreateFile(cSrc, GENERIC_WRITE,;
    FILE_SHARE_WRITE, 0, OPEN_EXISTING,;
    FILE_ATTRIBUTE_NORMAL, 0)

IF hFile = INVALID_HANDLE_VALUE
    ? "Failed to open file:", GetLastError()
    RETURN
ENDIF

* set the file pointer 1024 bytes
* after the current file end
= SetFilePointer(hFile, 1024, 0, 2)

IF SetEndOfFile(hFile) = 0
    ? "Failed to extend the file:", GetLastError()
ENDIF

= CloseHandle(hFile)
My comment:
In the usage example on this page the file is extended by 1024 bytes beyond its current physical length.

Normally the added space is filled with zeroes. Though it is not completely safe to expect it to happen each time.

The function can be used for extending as well as for making files smaller. Be carefull not to test the truncation on files with any importance.

Files can also be truncated to zero size by calling the CreateFile by itself with the TRUNCATE_EXISTING flag.

See also: SetFileValidData
Word Index links for the SetEndOfFile :
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
Created: 2008-12-08 13:56:00
Modified: 2008-12-08 14:20:54
Visited in last 7 days: 10
User Contributed Notes:
There are no notes on this subject.


Copyright 2001-2017 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.37), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.80.132.10)
8 sec.Function: 'GdipScaleMatrix'
15 sec.Function: 'GdipTranslateMatrix'
22 sec.Function: 'WNetOpenEnum'
29 sec.Function: 'GetWindowText'
37 sec.Function: 'GetErrorMode'
46 sec.Function: 'GetDriveType'
55 sec.Function: 'GetModuleHandle'
1.12 min.Function: 'LockServiceDatabase'
1.35 min.Function: 'LsaLookupSids'
1.57 min.Function: 'CallWindowProc'
Google
Advertise here!