Results 1 to 4 of 4

Thread: How to close a file?

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 1999
    Location
    Istanbul, Turkey
    Posts
    6

    Question

    Hi!

    To learn a file's size and last modified date I open it with FileOpen API and get its hFile then use GetFileInformationByHandle to get its size and date. It's ok, but I couldn't close the file Is there a way to close it or is there another way to get file's size and date?

  2. #2
    Guest
    Use the WM_CLOSE message. Here is an example. It will close our App.

    Code for module.
    Code:
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Public Const WM_CLOSE = &H10
    Put this in a CommandButton on the Form.
    Code:
    Private Sub Command1_Click()
    
         retval = SendMessage(Me.hwnd, WM_CLOSE, ByVal CLng(1), ByVal "C:\")
    End Sub

  3. #3
    Guest
    Does this work?

    Declaration:
    Public Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle" (ByVal hObject As Long) As Long

    Usage:
    CloseHandle hFile



  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 1999
    Location
    Istanbul, Turkey
    Posts
    6

    Wink

    Yep! CloseHandle worked...

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