1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#include <windows.h>
void main()
{
HANDLE hFile;
HANDLE hMapFile;
hFile = CreateFile("MYhFILE.TXT", // create MYFILE.TXT
GENERIC_WRITE, // open for writing
FILE_SHARE_READ|FILE_SHARE_WRITE, // do not share
NULL, // no security
CREATE_ALWAYS, // overwrite existing
FILE_ATTRIBUTE_NORMAL | // normal file
FILE_FLAG_OVERLAPPED, // asynchronous I/O
NULL); // no attr. template
if (hFile == NULL)
{
MessageBox(NULL,"createfile ECHOUER","ODK example",MB_ICONEXCLAMATION); // process error
}
else
MessageBox(NULL,"createfile SUCCES","ODK example",MB_ICONEXCLAMATION);
hMapFile = CreateFileMapping(hFile, // Current file handle.
NULL, // Default security.
PAGE_READWRITE, // Read/write permission.
0, // Max. object size.
1024, // Size of hFile.
"MyFileMappingObject"); // Name of mapping object.
if (hMapFile == NULL)
{
MessageBox(NULL,"mapfile ECHOUER","ODK example",MB_ICONEXCLAMATION); // process error
}
else
MessageBox(NULL,"map SUCCES","ODK example",MB_ICONEXCLAMATION);
} |
Partager