Beruflich Dokumente
Kultur Dokumente
Seek
CString FileName = "C:\\test1.txt";
CFile File;
CFileException ex;
unsigned char Buffer[256];
CWaitCursor wait;
if ( !File.Open( FileName, CFile::modeWrite, &ex ) )
{
TCHAR Cause[255];
CString Str;
ex.GetErrorMessage(Cause, 255);
Str = _T("File could not be opened. Error = ");
Str += Cause;
AfxMessageBox(Str);
}
else
{
File.Seek(0, CFile::end); //go to end of file
File.Write(Buffer, 256); //append file
File.Close();
}
wait.Restore();
Bubble Sort
//PreTranslateMessage function
BOOL CEncrDlg::PreTranslateMessage(MSG* pMsg)
{
char EncryptionKey = 0x45;
//Random Key
CString temp;
if ( pMsg->message == WM_KEYDOWN && pMsg->wParam == 13 )
{
GetDlgItemText(IDC_EDIT1, temp);
for ( int a = 0; a < temp.GetLength(); a++ )
{
char code = temp.GetAt(a);
_asm
{
mov al,code
xor al,EncryptionKey
mov code,al
inc EncryptionKey
}
temp.SetAt(a, code);
Label1.put_Caption(temp);
}
return true;
}
return CDialog::PreTranslateMessage(pMsg);
}