Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // dilib.cpp: определяет экспортированные функции для приложения DLL.
- //
- #include "stdafx.h"
- #include <stdio.h>
- extern "C"
- {
- __declspec(dllexport) int ASyncRead(HANDLE hFile, char* FileContent, int size, DWORD offset)
- {
- DWORD nBytesRead;
- OVERLAPPED fOverLapped;
- ZeroMemory(&fOverLapped, sizeof(OVERLAPPED));
- fOverLapped.hEvent = CreateEvent(NULL, false, false, NULL);
- fOverLapped.Offset = offset;
- ReadFile(hFile, FileContent, 1024, NULL, &fOverLapped);
- WaitForSingleObject(fOverLapped.hEvent, INFINITE);
- GetOverlappedResult(hFile, &fOverLapped, &nBytesRead, false);
- return nBytesRead;
- }
- __declspec(dllexport) void ASyncWrite(HANDLE hFile, char* FileContent, DWORD *offset)
- {
- char buf[15];
- DWORD nBytesWritten;
- OVERLAPPED fOverLapped;
- ZeroMemory(&fOverLapped, sizeof(OVERLAPPED));
- fOverLapped.Offset = *offset;
- fOverLapped.hEvent = CreateEvent(NULL, false, false, NULL);
- WriteFile(hFile, FileContent, strlen(FileContent), NULL, &fOverLapped);
- WaitForSingleObject(fOverLapped.hEvent, INFINITE);
- *offset += strlen(FileContent);
- CloseHandle(fOverLapped.hEvent);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement