Programmieren - alles kontrollieren 4.934 Themen, 20.613 Beiträge

Program in der C++ MFC

leon26 / 4 Antworten / Flachansicht Nickles

hi,
ich möchte ein Program in der C++ MFC anwendung schreiben mit hilfe von CString was eine datei aufmacht und einliest z.B.Opera Datein.
Da ich in der MFC anwendung etwas ungeübt bin ,bin ich für eure Tipps und Ratschläge sehr dankbar.

hier ein auschnitt der Opera datein!!!


Opera Hotlist version 2.0
Options: encoding = utf8, version=3

#FOLDER
ID=11
NAME=Papierkorb
TRASH FOLDER=YES

-

#FOLDER
ID=12
NAME=-- Opera Software --
EXPANDED=YES

#URL
ID=13
NAME=Buy Opera
URL=http://www.opera.com/buy/
VISITED=1116766052
ICONFILE=www.opera.com.ico

#URL
ID=14
NAME=Distribute Opera
URL=http://distribute.opera.com/distribution/
VISITED=1116763181
ICONFILE=distribute.opera.com.ico

bei Antwort benachrichtigen
m_akif6 leon26 „Program in der C++ MFC“
Optionen

Hier ein Auszug aus der MSDN:



1.) CreateFile
This function creates, opens, or truncates a file, communications resource, disk device, or console. It returns a handle that can be used to access the object. It can also open and return a handle to a directory.

A remote application interface (RAPI) version of this function exists, and it is named CeCreateFile.

HANDLE CreateFile(
LPCTSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDispostion ,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile);
Parameters
lpFileName
[in] Pointer to a null-terminated string that specifies the name of the object (file, communications resource, disk device, console, or directory) to create or open.
If *lpFileName is a path, there is a default string size limit of MAX_PATH characters. This limit is related to how the CreateFile function parses paths.
When lpFileName points to a communications resource to open, you must include a colon after the name. For example, specify "COM1: " to open that port. When using IrCOMM, specify "COM3:".
dwDesiredAccess
[in] Specifies the type of access to the object. An application can obtain read access, write access, read-write access, or device query access. This parameter can be any combination of the following values.
Value Description
0 Specifies device query access to the object. An application can query device attributes without accessing the device.
GENERIC_READ Specifies read access to the object. Data can be read from the file and the file pointer can be moved. Combine with GENERIC_WRITE for read-write access.
GENERIC_WRITE Specifies write access to the object. Data can be written to the file and the file pointer can be moved. Combine with GENERIC_READ for read-write access.
dwShareMode
[in] Specifies how the object can be shared. If dwShareMode is 0, the object cannot be shared. Subsequent open operations on the object will fail, until the handle is closed.
To share the object, use a combination of one or more of the following values:
Value Description
FILE_SHARE_READ Subsequent open operations on the object will succeed only if read access is requested.
FILE_SHARE_WRITE Subsequent open operations on the object will succeed only if write access is requested.
lpSecurityAttributes
[in] Ignored; set to NULL.
dwCreationDispostion
[in] Specifies which action to take on files that exist, and which action to take when files do not exist. For more information about this parameter, see the Remarks section. This parameter must be one of the following values:
Value Description
CREATE_NEW Creates a new file. The function fails if the specified file already exists.
CREATE_ALWAYS Creates a new file. If the file exists, the function overwrites the file and clears the existing attributes.
OPEN_EXISTING Opens the file. The function fails if the file does not exist.
See the Remarks section for a discussion of why you should use the OPEN_EXISTING flag if you are using the CreateFile function for devices, including the console.
OPEN_ALWAYS Opens the file, if it exists. If the file does not exist, the function creates the file as if dwCreationDisposition were CREATE_NEW.
TRUNCATE_EXISTING Opens the file. Once opened, the file is truncated so that its size is zero bytes. The calling process must open the file with at least GENERIC_WRITE access. The function fails if the file does not exist.
dwFlagsAndAttributes
[in] Specifies the file attributes and flags for the file.
Any combination of the following attributes is acceptable for the dwFlagsAndAttributes parameter, except all other file attributes override FILE_ATTRIBUTE_NORMAL.
Value Description
FILE_ATTRIBUTE_ARCHIVE The file should be archived. Applications use this attribute to mark files for backup or removal.
FILE_ATTRIBUTE_HIDDEN The file is hidden. It is not to be included in an ordinary directory listing.
FILE_ATTRIBUTE_NORMAL The file has no other attributes set. This attribute is valid only if used alone.
FILE_ATTRIBUTE_READONLY The file is read only. Applications can read the file but cannot write to it or delete it.
FILE_ATTRIBUTE_SYSTEM The file is part of or is used exclusively by the operating system.
FILE_ATTRIBUTE_TEMPORARY Not supported.

Any combination of the following flags is acceptable for the dwFlagsAndAttributes parameter.

Value Description
FILE_FLAG_WRITE_THROUGH Instructs the system to write through any intermediate cache and go directly to disk. The system can still cache write operations, but cannot lazily flush them.
FILE_FLAG_OVERLAPPED This flag is not supported; however, multiple reads/writes pending on a device at a time are allowed.
FILE_FLAG_RANDOM_ACCESS Indicates that the file is accessed randomly. The system can use this as a hint to optimize file caching.

hTemplateFile
[in] Ignored; as a result, CreateFile does not copy the extended attributes to the new file.



2.) DANACH RUFST DU "READFILE" auf:


This function reads data from a file, starting at the position indicated by the file pointer. After the read operation has been completed, the file pointer is adjusted by the number of bytes actually read.

BOOL ReadFile(
HANDLE hFile,
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped);
Parameters
hFile
[in] Handle to the file to be read. The file handle must have been created with GENERIC_READ access to the file. This parameter cannot be a socket handle.
lpBuffer
[out] Pointer to the buffer that receives the data read from the file.
nNumberOfBytesToRead
[in] Number of bytes to be read from the file.
lpNumberOfBytesRead
[out] Pointer to the number of bytes read. ReadFile sets this value to zero before doing any work or error checking.
lpOverlapped
[in] Unsupported; set to NULL.

bei Antwort benachrichtigen