M
MyCatAlex
Guest
I have this code that has been generously supplied by the user RLWA32. The following is the top of the file, a fraction. I changed the function name because I need to call it from another file.
int Sending_To_SSD()
{
// Create a 0 byte, empty file
HANDLE hFile = CreateFile(_T("SphHarm.dat"), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
_tprintf_s(_T("CreateFile failed with error %d\n"), GetLastError());
return 1;
}
DWORD dwMaxSize = MAX_FLOATS * sizeof(float);
HANDLE hMap = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, dwMaxSize, NULL);
if (!hMap)
{
_tprintf_s(_T("CreateFileMapping failed with error %d\n"), GetLastError());
return 1;
}
// map the entire file into the view
float* pfArray = (float*)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if (!pfArray)
{
_tprintf_s(_T("MapViewOfFile failed with error %d\n"), GetLastError());
return 1;
}
I also did a little surgery, removed comments and a printf statement. I wonder why the map file cannot be created? Thanks, - MyCatAlex
Continue reading...
int Sending_To_SSD()
{
// Create a 0 byte, empty file
HANDLE hFile = CreateFile(_T("SphHarm.dat"), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
_tprintf_s(_T("CreateFile failed with error %d\n"), GetLastError());
return 1;
}
DWORD dwMaxSize = MAX_FLOATS * sizeof(float);
HANDLE hMap = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, dwMaxSize, NULL);
if (!hMap)
{
_tprintf_s(_T("CreateFileMapping failed with error %d\n"), GetLastError());
return 1;
}
// map the entire file into the view
float* pfArray = (float*)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if (!pfArray)
{
_tprintf_s(_T("MapViewOfFile failed with error %d\n"), GetLastError());
return 1;
}
I also did a little surgery, removed comments and a printf statement. I wonder why the map file cannot be created? Thanks, - MyCatAlex
Continue reading...