Newsgroup: it.comp.lang.visual-basic
Titolo: Data di creazione di un file

Salve io ho il seguente codice:
Dim handle As Long
Dim Filenum As Integer
Filenum = 1
Open "c:\test.bmp" For Binary As Filenum
handle = FileAttr(Filenum, 2)    *
VB mi dice errore n. 5 (Invalid Procedire Call) alla riga *. Se invece
metto 1 allora funziona.
A me serve l'handle del file per poi trovarne la data tramite la
GetFileTime.
Secondo voi qual e' il problema?
Qualcuno conosce un altro modo per ottenere la data di creazione di un
file??
Grazie a tutti, Ciao

OK ho trovato la soluzione al problema: l'opzione con parametro 2 non e'
supportata sui sistemi operativi a 32 bit. E allora come la ricavo sta
benedetta data di Creazione del file?
Grazie a tutti, CarloPro


Per ottenere l'handle di un file si usa la funzione CreateFile:
CUT HERE
----------------------------------------------------------------------------
--------
VB Declaration
Declare Function CreateFile& Lib "kernel32" Alias "CreateFileA" (ByVal _
lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As
Long, _
lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As
_
Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long)
Description	
All purpose routine for opening and creating files, pipes, mailslots,
communication services, devices, and consoles.
Use with VB
No problem.
Parameter	Type/Description
lpFileName	String—The name of the file to open.
dwDesiredAccess	Long—GENERIC_READ to allow read access to a device,
GENERIC_WRITE to allow write access to a device (may be combined). Zero to
allow you to obtain information for a device only.
dwShareMode	Long—0 for no sharing, FILE_SHARE_READ and/or FILE_SHARE_WRITE
to allow shared access to the file.
lpSecurityAttributes	SECURITY_ATTRIBUTES—Pointer to a SECURITY_ATTRIBUTES
structure defining security for the file (if supported by the operating
system).
dwCreationDisposition	Long—One of the following constants:CREATE_NEW:
Create the file. Error occurs if file exists.CREATE_ALWAYS: Create the
file. Overwrites previous file.OPEN_EXISTING: File must already exist.
Required for devices.OPEN_ALWAYS: Creates the file if it does not already
exist.TRUNCATE_EXISTING: Truncates an existing file to zero length.
dwFlagsAndAttributes	Long—One or more of the following
constants:FILE_ATTRIBUTE_ARCHIVE: Marks the archive
attribute.FILE_ATTRIBUTE_COMPRESSED: Marks the file to be compressed, or
the default compression for files in a directory.FILE_ATTRIBUTE_NORMAL:
Default attributes.FILE_ATTRIBUTE_HIDDEN: File or directory is
hidden.FILE_ATTRIBUTE_READONLY: File is read only.FILE_ATTRIBUTE_SYSTEM:
File is a system file.FILE_FLAG_WRITE_THROUGH: Operating system does not
defer write operations on the file.FILE_FLAG_OVERLAPPED: Enables overlapped
operations on the file (See chapter text).FILE_FLAG_NO_BUFFERING: Disables
buffering of the file. Files can only be written in volume sector
blocks.FILE_FLAG_RANDOM_ACCESS: File buffering is optimized for random
access.FILE_FLAG_SEQUENTIAL_SCAN: File buffering is optimized for
sequential access.FILE_FLAG_DELETE_ON_CLOSE: Files is deleted when last
open handle is closed. Ideal for temporary files.You may also combine in
the following constant flags under Windows NT: SECURITY_ANONYMOUS,
SECURITY_IDENTIFICATION, SECURITY_IMPERSONATION, SECURITY_DELEGATION,
SECURITY_CONTEXT_TRACKING, SECURITY_EFFECTIVE_ONLY.
hTemplateFile	Long—If not zero, the handle to a file from which the new
file will copy extended attributes.
Return Value
Long—A file handle on success. INVALID_HANDLE_VALUE on error. Sets
GetLastError. GetLastError will be set to ERROR_ALREADY_EXISTS even if the
function succeeds if the file exists and CREATE_ALWAYS or OPEN_ALWAYS are
specified.
Platform
Windows 95, Windows NT
Comments
When opening a communication port (such as “Com1”) always specify
OPEN_EXISTING. Refer to the online Win32 API reference for additional
information on advanced features of this function.
Porting Notes
This function replaces and is preferred to the lOpen and lCreate functions.
----------------------------------------------------------------------------
--------------------
Ciao Marco
-- 
Remove xxx from E-mail.