Results 1 to 5 of 5

Thread: SetFilePointer

  1. #1

    Thread Starter
    Member
    Join Date
    May 2002
    Location
    Great Britain
    Posts
    60

    SetFilePointer

    I'm trying to use this API function as an alternative to Seek.

    I am a bit puzzled by two parameters:

    lDistancetoMove
    lDistancetoMoveHigh

    In what circumstances would I use the lDistancetoMoveHigh parameter? I'm guessing it's for use when you want to seek to a very high position in the file. In which case, how would I call the function to get to (for example) position 20,000,000 in a file?

    [EDIT]

    I'm going to try to be move specific. I am trying to get this function to work:

    Private Declare Function SetFilePointer Lib "kernel32" (ByVal hFile As Long, ByVal lDistanceToMove As Long, lpDistanceToMoveHigh As Long, ByVal dwMoveMethod As Long) As Long
    Private Declare Function SetEndOfFile Lib "kernel32" (ByVal hFile As Long) As Long


    Private Sub TruncateFile(FilePath As String, EndPosition As Long)
    Dim fHandle As Long
    fHandle = CreateFile(FilePath, GENERIC_WRITE, 0, vbNull, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, vbNull)
    SetFilePointer fHandle, EndPosition, 0, 0
    SetEndOfFile fHandle
    End Sub

    Notice that I don't use the lDistancetoMoveHigh parameter. Can someone help me get this to work?
    Last edited by CactusCat; Nov 3rd, 2002 at 01:34 PM.

  2. #2
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    It looks to me as though you've done everything correctly. What error or problem are you getting?

  3. #3

    Thread Starter
    Member
    Join Date
    May 2002
    Location
    Great Britain
    Posts
    60
    No problems with it, I'm just wondering what the use of it is (lpDistanceToMoveHigh parameter)

  4. #4
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    so you don't think that
    I am trying to get this function to work
    implies that you did NOT get it to work? I take it from your current comment that it DID work, yes?

  5. #5

    Thread Starter
    Member
    Join Date
    May 2002
    Location
    Great Britain
    Posts
    60
    It just emptys the file (File Size : 0)

    oh, I get it... I should've use '0' in place of 'vbNull'. God I'm stoopid

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width