Files in Windows API David Halbig Lopez.

Slides:



Advertisements
Similar presentations
Web siteWeb site ExamplesExamples 1 Mode of Operation Protected mode  4 GB  32-bit address  Windows, Linux Real-address mode  1 MB space  20-bit address.
Advertisements

WinAPI i System Plików 1. Volume Management 2. Disk Management 3. Directory Management 4. File Management Autor: Tomasz Jurkiewicz.
1 JMH Associates © 2004, All rights reserved Chapter 15 Asynchronous Input/Output.
1 JMH Associates © 2004, All rights reserved Chapter 1 Getting Started with Win32/64.
I/O Systems ◦ Operating Systems ◦ CS550. Note:  Based on Operating Systems Concepts by Silberschatz, Galvin, and Gagne  Strongly recommended to read.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS8: File System 8.5. Windows File and Directory.
Win32 Programming Lesson 13: Thread Pooling (Wow, Java is good for something…)
CS 470 Lab 5 Comment your code. Description of Lab5 Create Four projects – Driver – Producer – Filter – Consumer.
CP104 Introduction to Programming File I/O Lecture 33 __ 1 File Input/Output Text file and binary files File Input/output File input / output functions.
Introduction to the Windows API n API - Application Programming Interface n an API is the software interface for things such as the OS n an API is the.
Lecture 11 Dynamic link libraries. Differences between static libraries and DLLs In static library code is added to the executable. In DLL, the code is.
1 Week 12 l Overview of Streams and File I/O l Text File I/O Streams and File I/O.
GUI With GTK+ Under Linux Fanfan Xiong. Introduction GTK+ (GIMP toolkit) : A library for creating graphical user interfaces(GUI) Two examples developed.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Files & Directories.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS2: Operating System Principles 2.4. The Windows.
Win32 Programming Lesson 17: Memory Mapped Files (Finally, cool stuff again, all this work is getting tedious!)
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 1 due Friday, 7pm. RAD due next Friday. Presentations week 6. Today: –More details on functions,
1 Reverse a String iPhone/iPad, iOS Development Tutorial.
FILES. open() The open() function takes a filename and path as input and returns a file object. file object = open(file_name [, access_mode][, buffering])
System Programming Course introduction Getting Started …
Other Thread Synchronization Functions 井民全製作. Introduction.
Programming Fundamentals. Today’s Lecture Array Fundamentals Arrays as Class Member Data Arrays of Objects C-Strings The Standard C++ string Class.
C Programming Day 2. 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/LA07/003 Version No. 1.0 Union –mechanism to create user defined data types.
Our good old first Win32 programme of lecture 8 #include int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
Python C API overview References:
Threads and Thread Synchronization. Introduction In windows the basic unit of execution is the thread. It is the smallest schedulable unit of execution.
Lesson 3 Functions. Lesson 3 Functions are declared with function. For example, to calculate the cube of a number function function name (parameters)
File I/O. I/O Flags Flags are passed to give some information about how the file is to be used. – Read only file – flag=0x0 – Write only file – flag=0x1.
C++ Memory Management – Homework Exercises
CS501 Advanced Computer Architecture
File Management Mario Tayah and Jim Fawcett
Introduction to C++ Systems Programming.
Chapter 22 – part a Stream refer to any source of input or any destination for output. Many small programs, obtain all their input from one stream usually.
Streams and File I/O.
Windows Programming Lecture 09.
Z502 File System Contains: Disk Structure Description System Calls
CSE451 I/O Systems and the Full I/O Path Autumn 2002
Using Processes.
Principles of Operating Systems Lecture 8
Windows Concurrency Concepts and APIs
OpenStorage API part II
File Management.
C Basics.
Strings A string is a sequence of characters treated as a group
This pointer, Dynamic memory allocation, Constructors and Destructor
Changing WRF input files (met_em…) with MATLAB
CSC 253 Lecture 8.
Files I/O, Streams, I/O Redirection, Reading with fscanf
CSC 253 Lecture 8.
JAVA IO.
Windows APIs File Processing Copyright © 2016 Curt Hill.
Beginning C Lecture 11 Lecturer: Dr. Zhao Qinpei
files Dr. Bhargavi Goswami Department of Computer Science
Functions In Matlab.
Lesson 7. Events, Delegates, Generics.
Input - Output.
Designing a Method and Test Program
Explaining issues with DCremoval( )
Chapter 10-1: Dynamic Memory Allocation
Running a Java Program using Blue Jay.
Templates Generic Programming.
Mario Tayah and Jim Fawcett CSE775 – Distributed Objects Spring 2007
Templates CMSC 202, Version 4/02.
The CreateFile Function
EECE.2160 ECE Application Programming
Templates Generic Programming.
Professor Jodi Neely-Ritz University of Florida
SPL – PS2 C++ Memory Handling.
ME 123 Computer Applications I Lecture 8: System of Equations 3/21/03
Presentation transcript:

Files in Windows API David Halbig Lopez

What means files in Windows API? Files means all the things that we can do with files that exist on the system or that we create our files with code and then we used it in the way we like

Things to do with files In total we have more than 50 methods that use files But the most important are:Create, Copy, Read, Write and delete

How to create a file hFile = CreateFile(argv[1], // name of the write GENERIC_WRITE, // open for writing 0, // do not share NULL, // default security CREATE_NEW, // create new file only FILE_ATTRIBUTE_NORMAL, // normal file NULL); // no attr. template This is the code to code to create a file as we see the first is the name we want that that file has and we can use this even to open a file, the second is the desire of access for example in that argument we can use GENERIC_WRITE or GENERIC_READ so if we want to use both we just need to put both of them and then we can read and write that file, the third argument is for if we want that this file is opened more than one time at the same time but we have to take care because data can be overwritten, the fifth parameter is for if we want to create a new file CREATE_NEW or open an existing one OPEN_EXISTING. When we open a file so it create like a road between the file and our program

How to delete a file BOOL WINAPI DeleteFile( _In_ LPCTSTR lpFileName ); With the method delete we just need to use that method and as parameter we use the name of the file we want to delete if it fails return 0 and if dont fail return non zero

Read a file ReadFileEx(hFile, ReadBuffer, BUFFERSIZE-1, &ol, FileIOCompletionRoutine) With that method we we read from a file but first of all we need to open the file using the CreateFile method or with OpenFile method, then we can use it to read from a file So the first argument is the handler, the second one is a pointer to the buffer for example we can use an array where, the third is the number of bits that are going to be read The fouth is an OverLapped (Contains information used in asynchronous (or overlapped) input and output (I/O).) data structure. And the last one is FileIOCompletionRoutine callback function And it shows if the read method has been done correctly.

Write file WriteFile( hFile, // open file handle DataBuffer, // start of data to write dwBytesToWrite, // number of bytes to write &dwBytesWritten, // number of bytes that were written NULL); // no overlapped structure This is the method to write in a file as i said before, we have to be sure that we have open the file with the methods i said before because there must be a conection between the programm and the file and this method dont make that conection. So for make this method work we need the handles as first argument, the buffer that have all the data that we want to write on the file as second argument then how much bytes of that buffer we want to write as third argument, and the fourth one is a pointer to the variable that has the number of bytes to write, and the last one is the overlapped structure.

¿Questions? Source:https://msdn.microsoft.com/en-us/library/windows/desktop/bb540534(v=vs.85).aspx