本文整理汇总了C++中CleanUp函数的典型用法代码示例。如果您正苦于以下问题:C++ CleanUp函数的具体用法?C++ CleanUp怎么用?C++ CleanUp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CleanUp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CleanUp
//-------------------------------------------------------------------//
// RunInstalledVersion() //
//-------------------------------------------------------------------//
// This function is called if an EXE was run other than the one in
// the install path. It will set up to run the installed version.
// After returning from this function, the caller should quickly
// exit the currently running program.
//
// This function can update the installed version of the program with
// the one currently running, if bUpdate is true.
//
// This is not a straightforward task, because we cannot copy
// ourselves while we are running - Windows has the file exclusively
// locked.
//
// Instead, we fire off a hidden batch file. The batch file polls
// for a successful copy of this executable over the installed
// version. It will have to keep trying up until the point where
// this executable exits. So once we call this function, we want
// to exit the app as quickly as possible, so the whole machine
// does not grind to a halt. Note that the batch file's process is
// manhandled by this function to minimize its impact.
//
// An article in MSDN ( MSJ, Win Q & A, Deleting an executable ) has
// a comprehensive discussion of the problem of operating on the
// file of a running executable. The concept and original code were
// taken from there.
//-------------------------------------------------------------------//
void BaseApp::RunInstalledVersion(
bool bUpdate
) {
// Delete the shared memory, so the installed version can create it
// properly on its own.
CleanUp();
// We want to get the short filename for the installation directory.
// Make sure we create it first, or GetShortFilename() returns a blank string!!
VERIFY( MakeDir( m_strRegistryPath ) );
CString strRegistryFilename = AddTrailingBackslash( GetShortFilename( m_strRegistryPath ) ) + m_strExeName;
if ( !bUpdate )
{
ShellExecute(
NULL,
_T("open"),
LPCTSTR( m_strExeName ),
LPCTSTR( pCommandLine->m_strFileName ), // pointer to string that specifies executable-file parameters.
LPCTSTR( m_strRegistryPath ), // pointer to string that specifies default directory.
SW_SHOW // whether file is shown when opened.
);
}
else
{
// Get the current filename. Convert it to a short name,
// so the batch file works.
CString strCurrentFilename = GetShortFilename( GetProgramFilename() );
// We now replace the installed version of the EXE using
// a batch file.
// We need to do some prepping.
// We need to make sure the installed file is deleted before we
// call the batch file. It polls for existance of the file, and
// we don't want it to find it until we successfully copied it.
// We could let the batch file do this, but minimizing the batch
// file's requirements helps us minimize its impact. Besides,
// this may not succeed. Typically, this fails if the executable is
// already running. If so, the user is prolly farting around. We just exit.
bool bInstallIsDeleted = !bFileExists( strRegistryFilename );
if ( !bInstallIsDeleted )
bInstallIsDeleted = ( DeleteFile( strRegistryFilename ) != FALSE );
if ( bInstallIsDeleted )
{
// Create a temporary batch file.
// We create it in c:\.
// TO DO
// Consider using %TEMP%.
#define BATCH_FILE_NAME _T("c:\\Temp.bat")
#define BATCH_FILE_PATH _T("c:\\")
HANDLE hfile;
STARTUPINFO si;
PROCESS_INFORMATION pi;
hfile = CreateFile(
BATCH_FILE_NAME,
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
NULL
);
if ( hfile != INVALID_HANDLE_VALUE )
{
// Construct the lines for the batch file.
CString strBatFile;
//.........这里部分代码省略.........
示例2: CleanUp
CWayPointManager::~CWayPointManager()
{
CleanUp();
}
示例3: CleanUp
cSkinnedMesh::~cSkinnedMesh()
{
CleanUp();
}
示例4: CleanUp
CParticleSettingsManager::~CParticleSettingsManager()
{
CleanUp();
}
示例5: CleanUp
CException::~CException() {
CleanUp();
};
示例6: CleanUp
p4dn::Error::~Error( void )
{
CleanUp();
}
示例7: ERROR_INFO
//.........这里部分代码省略.........
if (m_Rslt == MEASUREMENT_VALID)
{
if (m_backlashResultMs >= 0.8 * m_northPulseCount * m_pulseWidth)
m_Rslt = MEASUREMENT_IMPAIRED; // May not have moved far enough north for accurate measurement
}
Debug.AddLine(wxString::Format("BLT: Backlash amount is %0.2f px, %d ms", m_backlashResultPx, m_backlashResultMs));
// Don't try this refinement if the clearing pulse will cause us to lose the star
if (m_backlashResultPx < pFrame->pGuider->GetMaxMovePixels())
{
m_lastStatus = wxString::Format(_("Issuing test backlash correction of %d ms"), m_backlashResultMs);
Debug.AddLine(m_lastStatus);
// This should put us back roughly to where we issued the big North pulse unless the backlash is very large
pFrame->ScheduleCalibrationMove(m_scope, SOUTH, m_backlashResultMs);
m_stepCount++;
}
else
{
int maxFrameMove = (int)floor((double)pFrame->pGuider->GetMaxMovePixels() / m_northRate);
Debug.AddLine(wxString::Format("BLT: Clearing pulse is very large, issuing max S move of %d", maxFrameMove));
pFrame->ScheduleCalibrationMove(m_scope, SOUTH, maxFrameMove); // One more pulse to cycle the state machine
m_bltState = BLT_STATE_RESTORE;
}
break;
}
// See how close we came, maybe fine-tune a bit
Debug.AddLine(wxString::Format("BLT: Trial backlash pulse resulted in net DecDelta = %0.2f px, Dec Location %0.2f", decDelta, currMountLocation.Y));
if (fabs(decDelta) > TRIAL_TOLERANCE)
{
double pulse_delta = fabs(currMountLocation.Y - m_endSouth.Y);
if ((m_endSouth.Y - m_markerPoint.Y) * decDelta < 0) // Sign change, went too far
{
m_backlashResultMs *= m_backlashResultPx / pulse_delta;
Debug.AddLine(wxString::Format("BLT: Trial backlash resulted in overshoot - adjusting pulse size by %0.2f", m_backlashResultPx / pulse_delta));
}
else
{
double corr_factor = (m_backlashResultPx / pulse_delta - 1.0) * 0.5 + 1.0; // apply 50% of the correction to avoid over-shoot
//m_backlashResultMs *= corr_factor;
Debug.AddLine(wxString::Format("BLT: Trial backlash resulted in under-correction - under-shot by %0.2f", corr_factor));
}
}
else
Debug.AddLine("BLT: Initial backlash pulse resulted in final delta of < 2 px");
m_bltState = BLT_STATE_RESTORE;
m_stepCount = 0;
// fall through
case BLT_STATE_RESTORE:
// We could be a considerable distance from where we started, so get back close to the starting point without losing the star
if (m_stepCount == 0)
{
Debug.AddLine(wxString::Format("BLT: Starting Dec position at %0.2f, Ending Dec position at %0.2f", m_markerPoint.Y, currMountLocation.Y));
amt = fabs(currMountLocation.Y - m_startingPoint.Y);
if (amt > pFrame->pGuider->GetMaxMovePixels())
{
m_restoreCount = (int)floor((amt / m_northRate) / m_pulseWidth);
Debug.AddLine(wxString::Format("BLT: Final restore distance is %0.1f px, approx %d steps", amt, m_restoreCount));
m_stepCount = 0;
}
else
m_bltState = BLT_STATE_WRAPUP;
}
if (m_stepCount < m_restoreCount)
{
pFrame->ScheduleCalibrationMove(m_scope, SOUTH, m_pulseWidth);
m_stepCount++;
m_lastStatus = _("Restoring star position");
Debug.AddLine("BLT: Issuing restore pulse count %d of %d ms", m_stepCount, m_pulseWidth);
break;
}
m_bltState = BLT_STATE_WRAPUP;
// fall through
case BLT_STATE_WRAPUP:
m_lastStatus = _("Measurement complete");
CleanUp();
m_bltState = BLT_STATE_COMPLETED;
break;
case BLT_STATE_COMPLETED:
break;
case BLT_STATE_ABORTED:
m_lastStatus = _("Measurement halted");
Debug.AddLine("BLT: measurement process halted by user");
CleanUp();
break;
} // end of switch on state
}
catch (const wxString& msg)
{
Debug.AddLine(wxString::Format("BLT: Exception thrown in logical state %d", (int)m_bltState));
m_bltState = BLT_STATE_ABORTED;
m_lastStatus = _("Measurement encountered an error: " + msg);
Debug.AddLine("BLT: " + m_lastStatus);
CleanUp();
}
}
示例8: CleanUp
MaleFirstNameDataFileRecordTestCases::~MaleFirstNameDataFileRecordTestCases()
{
CleanUp( &dfr1 );
}
示例9: Cancel
virtual void Cancel()
{
CleanUp();
//our object has been destructed at this point
}
示例10: main
int main (int argc, const char * argv[]) {
/* Init stack pointers, capitilization shows priority and letter describes direction */
EStack = (TStack *)malloc(sizeof(TStack));
eStack = (TStack *)malloc(sizeof(TStack));
WStack = (TStack *)malloc(sizeof(TStack));
wStack = (TStack *)malloc(sizeof(TStack));
EStack->Head = NULL; eStack->Head = NULL; WStack->Head = NULL; wStack->Head = NULL;
EStack->Count = 0; eStack->Count = 0; WStack->Count = 0; wStack->Count = 0;
EStack->StackUse = 0; eStack->StackUse = 0; WStack->StackUse = 0; wStack->StackUse = 0;
/* init parameters */
inFileName = argv[1];
NumTrains = atoi(argv[2]); TrainsFinished = 0;TrackInUse = 0;
LastDirection = (char*)malloc(sizeof(char)*4);
strcpy(LastDirection, "East");
if (inFileName == NULL || NumTrains == 0) {
printf("Usage : ./mts [inputfile] [number of trains]\n");
return 1;
}
/* init stack mutexes */
pthread_mutex_init (&eStack->Mutex, NULL);pthread_mutex_init (&wStack->Mutex, NULL);pthread_mutex_init (&WStack->Mutex, NULL);
pthread_mutex_init (&EStack->Mutex, NULL);pthread_cond_init (&EStack->Cv, NULL);pthread_cond_init (&eStack->Cv, NULL);
pthread_cond_init (&WStack->Cv, NULL);pthread_cond_init (&wStack->Cv, NULL);pthread_mutex_init (&TrackMutex, NULL);
pthread_cond_init (&TrackState, NULL);
ReadFile(); /* Read the file, and setup the Loading array */
int i = 0;
for (LoadingCurrent = LoadingThreads; i < NumTrains; LoadingCurrent++) {
pthread_mutex_init(&LoadingCurrent->TMutex, NULL);
pthread_cond_init(&LoadingCurrent->TState, NULL);
pthread_create(&LoadingCurrent->tid, NULL, train, (void *)LoadingCurrent);
i++;
}
/* Main scheduling loop, wait until all trains are finished. */
while (TrainsFinished < NumTrains) {
if (TrackInUse) {
pthread_cond_wait(&TrackState, &TrackMutex);
pthread_mutex_unlock(&TrackMutex);
if (TrainsFinished == NumTrains)
break;
}
if (EStack->Count || WStack->Count) { /* EStack or WStack is not NULL */
if (EStack->Count && WStack->Count) {
if (strcmp(LastDirection, "East") == 0) { /* if the last direction was east, send west */
pthread_mutex_lock(&TrackMutex);
pthread_cond_signal(&WStack->Current->TState);
}
else {
pthread_mutex_lock(&TrackMutex);
pthread_cond_signal(&EStack->Current->TState);
}
}
else if (EStack->Count) { /* If EStack is not NULL */
pthread_mutex_lock(&TrackMutex);
pthread_cond_signal(&EStack->Current->TState);
}
else if (WStack->Count) { /* If WStack is not NULL */
pthread_mutex_lock(&TrackMutex);
pthread_cond_signal(&WStack->Current->TState);
}
}
else if (wStack->Count || eStack->Count) { /* eStack or wStack != NULL */
if (eStack->Count && wStack->Count) {
if (strcmp(LastDirection, "East") == 0) { /* if the last direction was east, send west */
pthread_mutex_lock(&TrackMutex);
pthread_cond_signal(&wStack->Current->TState);
}
else {
pthread_mutex_lock(&TrackMutex);
pthread_cond_signal(&eStack->Current->TState);
}
}
else if (eStack->Count) { /* if the low pri east stack is not NULL */
pthread_mutex_lock(&TrackMutex);
pthread_cond_signal(&eStack->Current->TState);
}
else if (wStack->Count) { /* if the low pri west stack is not NULL */
pthread_mutex_lock(&TrackMutex);
pthread_cond_signal(&wStack->Current->TState);
}
}
pthread_mutex_unlock(&TrackMutex);
}
CleanUp();
pthread_exit(NULL);
}
示例11: main
int __cdecl main(int argc, char *argv[])
{
HANDLE hFile = NULL;
DWORD dwBytesWritten;
const char* hugeStringTest =
"1234567890123456789012345678901234567890";
const char* szWritableFile = "writeable.txt";
int i =0;
if (0 != PAL_Initialize(argc,argv))
{
return FAIL;
}
/* create the test file */
hFile = CreateFile(szWritableFile,
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if(hFile == INVALID_HANDLE_VALUE)
{
Fail("WriteFile: ERROR -> Unable to create file \"%s\".\n",
szWritableFile);
}
/* write 4000 000 chars to the file.*/
for (i=0; i<100000;i++)
{
if( WriteFile(hFile, /* HANDLE handle to file */
hugeStringTest, /* data buffer */
strlen(hugeStringTest), /* number of bytes to write */
&dwBytesWritten, /* number of bytes written */
NULL) /* overlapped buffer */
==0)
{
Trace("WriteFile: ERROR -> Unable to write to file error: %ld \n",
GetLastError());
CleanUp(hFile,szWritableFile);
Fail("");
}
}
if(!FlushFileBuffers(hFile))
{
Trace("WriteFile: ERROR -> Call to FlushFileBuffers failed"
"error %ld \n",GetLastError());
CleanUp(hFile,szWritableFile);
Fail("");
}
/* test if the size changed properly. */
if(GetFileSize(hFile,NULL) != 4000000)
{
Trace("WriteFile: ERROR -> file size did not change properly"
" after writing 4000 000 chars to it ( size= %u )\n",
GetFileSize(hFile,NULL));
CleanUp(hFile,szWritableFile);
Fail("");
}
if (!CleanUp(hFile,szWritableFile))
{
Fail("");
}
PAL_Terminate();
return PASS;
}
示例12: CleanUp
/**
* Schliesst das Fenster.
*
* @author FloSoft
*/
void VideoSDL::DestroyScreen(void)
{
// Fenster schliessen
CleanUp();
Initialize();
}
示例13: CleanUp
ResultSet::~ResultSet()
{
CleanUp();
}
示例14: m_rowCount
//.........这里部分代码省略.........
m_length(NULL)
{
if (!m_res)
return;
if (m_stmt->bind_result_done)
{
delete[] m_stmt->bind->length;
delete[] m_stmt->bind->is_null;
}
m_rBind = new MYSQL_BIND[m_fieldCount];
m_isNull = new my_bool[m_fieldCount];
m_length = new unsigned long[m_fieldCount];
memset(m_isNull, 0, sizeof(my_bool) * m_fieldCount);
memset(m_rBind, 0, sizeof(MYSQL_BIND) * m_fieldCount);
memset(m_length, 0, sizeof(unsigned long) * m_fieldCount);
//- This is where we store the (entire) resultset
if (mysql_stmt_store_result(m_stmt))
{
TC_LOG_WARN("sql.sql", "%s:mysql_stmt_store_result, cannot bind result from MySQL server. Error: %s", __FUNCTION__, mysql_stmt_error(m_stmt));
delete[] m_rBind;
delete[] m_isNull;
delete[] m_length;
return;
}
//- This is where we prepare the buffer based on metadata
uint32 i = 0;
MYSQL_FIELD* field = mysql_fetch_field(m_res);
while (field)
{
size_t size = Field::SizeForType(field);
m_rBind[i].buffer_type = field->type;
m_rBind[i].buffer = malloc(size);
memset(m_rBind[i].buffer, 0, size);
m_rBind[i].buffer_length = size;
m_rBind[i].length = &m_length[i];
m_rBind[i].is_null = &m_isNull[i];
m_rBind[i].error = NULL;
m_rBind[i].is_unsigned = field->flags & UNSIGNED_FLAG;
++i;
field = mysql_fetch_field(m_res);
}
//- This is where we bind the bind the buffer to the statement
if (mysql_stmt_bind_result(m_stmt, m_rBind))
{
TC_LOG_WARN("sql.sql", "%s:mysql_stmt_bind_result, cannot bind result from MySQL server. Error: %s", __FUNCTION__, mysql_stmt_error(m_stmt));
delete[] m_rBind;
delete[] m_isNull;
delete[] m_length;
return;
}
m_rowCount = mysql_stmt_num_rows(m_stmt);
m_rows.resize(uint32(m_rowCount));
while (_NextRow())
{
m_rows[uint32(m_rowPosition)] = new Field[m_fieldCount];
for (uint64 fIndex = 0; fIndex < m_fieldCount; ++fIndex)
{
if (!*m_rBind[fIndex].is_null)
m_rows[uint32(m_rowPosition)][fIndex].SetByteValue(m_rBind[fIndex].buffer,
m_rBind[fIndex].buffer_length,
m_rBind[fIndex].buffer_type,
*m_rBind[fIndex].length);
else
switch (m_rBind[fIndex].buffer_type)
{
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING:
m_rows[uint32(m_rowPosition)][fIndex].SetByteValue("",
m_rBind[fIndex].buffer_length,
m_rBind[fIndex].buffer_type,
*m_rBind[fIndex].length);
break;
default:
m_rows[uint32(m_rowPosition)][fIndex].SetByteValue(nullptr,
m_rBind[fIndex].buffer_length,
m_rBind[fIndex].buffer_type,
*m_rBind[fIndex].length);
}
}
m_rowPosition++;
}
m_rowPosition = 0;
/// All data is buffered, let go of mysql c api structures
CleanUp();
}
示例15: CleanUp
/*
================
idEntityFx::Stop
================
*/
void idEntityFx::Stop( void ) {
CleanUp();
started = -1;
}