open1.jpg open2.jpg config1.jpg

 
/* Handle.cpp */
 
#undef UNICODE
#include <windows.h> // CreateFile, ...
#include <stdio.h> // printf, scanf
 
int main (int argc, char * argv [])
{
    HANDLE h =
      CreateFile
        ("abc.TXT",	// pointer to name of the file
          /* GENERIC_READ | */ GENERIC_WRITE,	// access (read-write) mode
          0,	// share mode
          NULL, // pointer to security attributes
          OPEN_ALWAYS,	// how to create
          FILE_ATTRIBUTE_NORMAL,	// file attributes
          NULL // handle to file with attributes to copy
         );
 
    if (h == INVALID_HANDLE_VALUE)
    {
        int n = GetLastError ();
        printf ("CHYBA %d", n);
    }
    else
    {
        char pole [] = "ABCD";
        DWORD delka = 4;
        DWORD odpoved;
        BOOL b = WriteFile (h, pole, delka, &odpoved, NULL);
        if (! b || odpoved != delka)
           printf ("CHYBA PRI ZAPISU \n");
        else
           printf ("POVEDLO SE TO \n");
        CloseHandle (h);
    }
 
    /*
     ReadFile
     WriteFile
     FileSeek
     CloseHandle
     CreateFileMapping
     */
 
	printf ("Stiskni enter \n");
	char c;
	scanf_s ("%c", &c);
 
	return 0;
}

small.vcproj

 
filehandles.txt · Last modified: 2009/03/19 12:44 by 147.32.8.115
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki