PDA

Click to See Complete Forum and Search --> : How to close a file?


Wizard
Jun 21st, 2000, 03:43 PM
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?

Jun 22nd, 2000, 01:03 AM
Use the WM_CLOSE message. Here is an example. It will close our App.

Code for module.

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.

Private Sub Command1_Click()

retval = SendMessage(Me.hwnd, WM_CLOSE, ByVal CLng(1), ByVal "C:\")
End Sub

Jun 22nd, 2000, 04:39 PM
Does this work?

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

Usage:
CloseHandle hFile

Wizard
Jun 22nd, 2000, 04:46 PM
Yep! CloseHandle worked...