setfilepointerevent.cpp
来自「IO函数调用测试」· C++ 代码 · 共 154 行
CPP
154 行
#include "stdafx.h"
#include "IOExplorer.h"
#include "TraceEvent.h"
#include "SetFilePointerEvent.h"
/****************************************************************************
* SetFilePointerEvent::SetFilePointerEvent
* Inputs:
* CString s: Name of handle
* HANDLE hv: Actual handle, or 0 if not known
* DWORD BytesToMove
* DWORD BytesToMoveHigh
* DWORD mode
* Effect:
* Initializes the SetFilePointerEvent
****************************************************************************/
SetFilePointerEvent::SetFilePointerEvent(CString s, HANDLE hv, DWORD BytesToMove, DWORD BytesToMoveHigh, DWORD MoveMode)
{
h = hv;
name = s;
this->BytesToMove = BytesToMove;
this->BytesToMoveHigh = BytesToMoveHigh;
this->MoveMode = MoveMode;
}
CString SetFilePointerEvent::display_result()
{
CString s;
if(result == 0xFFFFFFFF)
s.Format(_T("0x%08x"), result);
else
s.Format(_T("%u"), result);
return s;
}
/****************************************************************************
* SetFilePointerEvent::execute
* Result: LRESULT
* LRESULT low-order 32 bits of new file pointer
* (LRESULT)0xFFFFFFFF if error
* Effect:
* Closes the handle whose handle value is supplied in the event block
* Notes:
* If the SetFilePointer function succeeds, the return value is the
* low-order doubleword of the new file pointer, and if
* lpDistanceToMoveHigh is not NULL, the function puts the high-order
* doubleword of the new file pointer into the LONG pointed to by that
* parameter. If the function fails and lpDistanceToMoveHigh is NULL,
* the return value is 0xFFFFFFFF. To get extended error information,
* call GetLastError. If the function fails, and lpDistanceToMoveHigh is
* non-NULL, the return value is 0xFFFFFFFF and GetLastError will return
* a value other than NO_ERROR.
****************************************************************************/
LRESULT SetFilePointerEvent::execute()
{
LPLONG High = NULL; // or &BytesToMoveHigh when implemented
if(h == NULL)
return FALSE; // bogus
CWaitCursor c;
result = SetFilePointer(h, BytesToMove, High, MoveMode);
if(result == 0xFFFFFFFF)
{ /* error or ok64 */
if(High == NULL)
{ /* error, 32-bit */
lasterror = ::GetLastError();
} /* error, 32-bit */
else
{ /* error, 64-bit */
lasterror = ::GetLastError();
} /* error, 64-bit */
} /* error or ok64 */
else
{ /* ok 32 */
lasterror = 0;
} /* ok 32 */
return result;
}
/****************************************************************************
* SetFilePointerEvent::display
* Result: CString
* Display string for the event
* Effect:
* Creates a displayable string
****************************************************************************/
CString SetFilePointerEvent::display()
{
CString handle;
if(h == NULL)
{ /* no handle */
if(name.GetLength() == 0)
{ /* no name */
handle = _T("");
} /* no name */
else
{ /* has name */
handle = name;
} /* has name */
} /* no handle */
else
{ /* valid handle */
handle = name;
} /* valid handle */
CString highstring;
highstring.LoadString(IDS_NULL); // High load not implemented yet
CString mode;
switch(MoveMode)
{ /* mode */
case FILE_BEGIN:
mode.LoadString(IDS_FILE_BEGIN);
break;
case FILE_CURRENT:
mode.LoadString(IDS_FILE_CURRENT);
break;
case FILE_END:
mode.LoadString(IDS_FILE_END);
break;
default:
mode.Format(_T("%d"), MoveMode);
break;
} /* mode */
CString rf;
rf.Format(_T("SetFilePointer(%s, %d, %s, %s)"),
handle, BytesToMove, highstring, mode);
return rf;
}
/****************************************************************************
* SetFilePointerEvent::copy
* Result: TraceEvent *
* A copy of the trace event
* Effect:
* Makes a complete copy of the TraceEvent
****************************************************************************/
TraceEvent * SetFilePointerEvent::copy()
{
SetFilePointerEvent * e = new SetFilePointerEvent(name, h, BytesToMove, BytesToMoveHigh, MoveMode);
copyTraceData(e);
return e;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?