ayuda con api 'abrir archivo'

10/07/2003 - 20:57 por leonardo | Informe spam
Hola Grupo,:

estoy construyendo una aplicacion, en la cual necesito utilizar la api de
windows que are un archivo.

ahora nose como utilizarla y que parametros me debuelve.

si alguien pudiera guiarme se lo agradeceria muchisimo.

salu2 a todos

Preguntas similare

Leer las respuestas

#1 Daniel García
10/07/2003 - 21:50 | Informe spam
Hola Leonardo:
Te envío los parámetros de la API OpenFile que supongo es a la que te
refieres. Ejemplos y modos de uso puedes encontrarlos en allapi.net que es
de donde obtuve la información (en ingléss) que adjunto.

Ojalá te sirva.
Saludos,
daniel

· lpFileName
Points to a null-terminated string that names the file to be opened. The
string must consist of characters from the Windows 3.x character set. The
OpenFile function does not support Unicode filenames.

· lpReOpenBuff
Points to the OFSTRUCT structure that receives information about the file
when it is first opened. The structure can be used in subsequent calls to
the OpenFile function to refer to the open file.
The OFSTRUCT structure contains a pathname string member whose length is
limited to OFS_MAXPATHNAME characters. OFS_MAXPATHNAME is currently defined
to be 128. Because of this, you cannot use the OpenFile function to open a
file whose path length exceeds 128 characters. The CreateFile function does
not have such a path length limitation.

· uStyle
Specifies the action to take. The following values can be combined by using
the bitwise OR operator:
OF_CANCEL
Ignored. In the Win32 application programming interface (API), the
OF_PROMPT style produces a dialog box containing a Cancel button.
OF_CREATE
Creates a new file. If the file already exists, it is truncated to zero
length.
OF_DELETE
Deletes the file.
OF_EXIST
Opens the file and then closes it. Used to test for a file’s existence.
OF_PARSE
Fills the OFSTRUCT structure but carries out no other action.
OF_PROMPT
Displays a dialog box if the requested file does not exist. The dialog box
informs the user that Windows cannot find the file, and it contains Retry
and Cancel buttons. Choosing the Cancel button directs OpenFile to return a
file-not-found error message.
OF_READ
Opens the file for reading only.
OF_READWRITE
Opens the file for reading and writing.
OF_REOPEN
Opens the file using information in the reopen buffer.
OF_SHARE_COMPAT
For MS-DOS-based file systems using the Win32 API, opens the file with
compatibility mode, allowing any process on a specified computer to open the
file any number of times. Other efforts to open with any other sharing mode
fail.
Windows NT: This flag is mapped to the CreateFile function's
FILE_SHARE_READ | FILE_SHARE_WRITE flags.
OF_SHARE_DENY_NONE
Opens the file without denying read or write access to other processes. On
MS-DOS-based file systems using the Win32 API, if the file has been opened
in compatibility mode by any other process, the function fails.
Windows NT: This flag is mapped to the CreateFile function's
FILE_SHARE_READ | FILE_SHARE_WRITE flags.
OF_SHARE_DENY_READ
Opens the file and denies read access to other processes. On MS-DOS-based
file systems using the Win32 API, if the file has been opened in
compatibility mode or for read access by any other process, the function
fails. Windows NT: This flag is mapped to the CreateFile function's
FILE_SHARE_WRITE flag.
OF_SHARE_DENY_WRITE
Opens the file and denies write access to other processes. On MS-DOS-based
file systems using the Win32 API, if the file has been opened in
compatibility mode or for write access by any other process, the function
fails.
Windows NT: This flag is mapped to the CreateFile function's
FILE_SHARE_READ flag.
OF_SHARE_EXCLUSIVE
Opens the file with exclusive mode, denying both read and write access to
other processes. If the file has been opened in any other mode for read or
write access, even by the current process, the function fails.
OF_VERIFY
Verifies that the date and time of the file are the same as when it was
previously opened. This is useful as an extra check for read-only files.
OF_WRITE
Opens the file for writing only.


"leonardo" wrote in message
news:
Hola Grupo,:

estoy construyendo una aplicacion, en la cual necesito utilizar la api de
windows que are un archivo.

ahora nose como utilizarla y que parametros me debuelve.

si alguien pudiera guiarme se lo agradeceria muchisimo.

salu2 a todos


Respuesta Responder a este mensaje
#2 Renato
11/07/2003 - 03:30 | Informe spam
Estan bien atrasados.
esa apies antigua. la que se utiliza ahora es
CreateFile

HANDLE CreateFile(
LPCTSTR lpFileName, // pointer to name of the file
DWORD dwDesiredAccess, // access (read-write) mode
DWORD dwShareMode, // share mode
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
// pointer to security attributes
DWORD dwCreationDisposition, // how to create
DWORD dwFlagsAndAttributes, // file attributes
HANDLE hTemplateFile // handle to file with attributes to
// copy
);


para abrir un archivo para lectura y escritura de la manera convencional haz
lo siguiente
Dim hFile as long
hFile CreateFile("Miarchiov.txt",GENERIC_READ+GENERIC_WRITE,0,0,OPEN_EXISTING,0,0)
Esa orden solo abre el archivo pero falla si es que este no existe
Si lo que quieres es crear un archivo nuevo o reemplzarlo cmabia
OPEN_EXISTING por CREATE_NEW + CREATE_ALWAYS

Ojala te sea de ayuda ;)
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida