本文整理汇总了C++中CKnownFile::IsKindOf方法的典型用法代码示例。如果您正苦于以下问题:C++ CKnownFile::IsKindOf方法的具体用法?C++ CKnownFile::IsKindOf怎么用?C++ CKnownFile::IsKindOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKnownFile
的用法示例。
在下文中一共展示了CKnownFile::IsKindOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnBnClickedOk
void CCollectionCreateDialog::OnBnClickedOk()
{
//Some users have noted that the collection can at times
//save a collection with a invalid name...
OnEnKillFocusCollectionName();
CString sFileName;
m_CollectionNameEdit.GetWindowText(sFileName);
if (!sFileName.IsEmpty())
{
m_pCollection->m_sCollectionAuthorName.Empty();
m_pCollection->SetCollectionAuthorKey(NULL, 0);
m_pCollection->m_sCollectionName = sFileName;
m_pCollection->m_bTextFormat = (m_CollectionCreateFormatCheck.GetCheck() == BST_CHECKED);
CString sFilePath;
sFilePath.Format(_T("%s\\%s.emulecollection"), thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR), m_pCollection->m_sCollectionName);
using namespace CryptoPP;
RSASSA_PKCS1v15_SHA_Signer* pSignkey = NULL;
if (m_CollectionCreateSignNameKeyCheck.GetCheck())
{
bool bCreateNewKey = false;
HANDLE hKeyFile = ::CreateFile(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + _T("collectioncryptkey.dat"), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hKeyFile != INVALID_HANDLE_VALUE)
{
if (::GetFileSize(hKeyFile, NULL) == 0)
bCreateNewKey = true;
::CloseHandle(hKeyFile);
}
else
bCreateNewKey = true;
if (bCreateNewKey)
{
try
{
AutoSeededRandomPool rng;
InvertibleRSAFunction privkey;
privkey.Initialize(rng, 1024);
Base64Encoder privkeysink(new FileSink(CStringA(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + _T("collectioncryptkey.dat"))));
privkey.DEREncode(privkeysink);
privkeysink.MessageEnd();
}
catch(...)
{
ASSERT(0);
}
}
try
{
FileSource filesource(CStringA(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + _T("collectioncryptkey.dat")), true,new Base64Decoder);
pSignkey = new RSASSA_PKCS1v15_SHA_Signer(filesource);
RSASSA_PKCS1v15_SHA_Verifier pubkey(*pSignkey);
byte abyMyPublicKey[1000];
ArraySink asink(abyMyPublicKey, 1000);
pubkey.DEREncode(asink);
int nLen = asink.TotalPutLength();
asink.MessageEnd();
m_pCollection->SetCollectionAuthorKey(abyMyPublicKey, nLen);
}
catch(...)
{
ASSERT(0);
}
m_pCollection->m_sCollectionAuthorName = thePrefs.GetUserNick();
}
if (!PathFileExists(sFilePath))
{
m_pCollection->WriteToFileAddShared(pSignkey);
}
else
{
if (AfxMessageBox(GetResString(IDS_COLL_REPLACEEXISTING), MB_ICONWARNING | MB_ICONQUESTION | MB_DEFBUTTON2 | MB_YESNO) == IDNO)
return;
bool bDeleteSuccessful = ShellDeleteFile(sFilePath);
if (bDeleteSuccessful)
{
CKnownFile* pKnownFile = theApp.knownfiles->FindKnownFileByPath(sFilePath);
if (pKnownFile)
{
theApp.sharedfiles->RemoveFile(pKnownFile, true);
if (pKnownFile->IsKindOf(RUNTIME_CLASS(CPartFile)))
theApp.emuledlg->transferwnd->GetDownloadList()->ClearCompleted(static_cast<CPartFile*>(pKnownFile));
}
m_pCollection->WriteToFileAddShared(pSignkey);
}
else
{
AfxMessageBox(GetResString(IDS_COLL_ERR_DELETING),MB_ICONWARNING | MB_ICONQUESTION | MB_DEFBUTTON2 | MB_YESNO);
}
}
delete pSignkey;
pSignkey = NULL;
//.........这里部分代码省略.........
示例2: OnCommand
BOOL CSharedDirsTreeCtrl::OnCommand(WPARAM wParam, LPARAM lParam)
{
CTypedPtrList<CPtrList, CKnownFile*> selectedList;
int iSelectedItems = m_pSharedFilesCtrl->GetItemCount();
for (int i = 0; i < iSelectedItems; i++)
{
selectedList.AddTail((CKnownFile*)m_pSharedFilesCtrl->GetItemData(i));
}
CDirectoryItem* pSelectedDir = GetSelectedFilter();
// folder based
if (pSelectedDir != NULL){
switch (wParam){
case MP_OPENFOLDER:
if (pSelectedDir && pSelectedDir->m_eItemType == SDI_NO){
ShellExecute(NULL, _T("open"), pSelectedDir->m_strFullPath, NULL, NULL, SW_SHOW);
}
break;
case MP_SHAREDIR:
EditSharedDirectories(pSelectedDir, true, false);
break;
case MP_SHAREDIRSUB:
EditSharedDirectories(pSelectedDir, true, true);
break;
case MP_UNSHAREDIR:
EditSharedDirectories(pSelectedDir, false, false);
break;
case MP_UNSHAREDIRSUB:
EditSharedDirectories(pSelectedDir, false, true);
break;
}
}
// file based
if (selectedList.GetCount() > 0 && pSelectedDir != NULL)
{
CKnownFile* file = NULL;
if (selectedList.GetCount() == 1)
file = selectedList.GetHead();
switch (wParam){
case MP_GETED2KLINK:{
CString str;
POSITION pos = selectedList.GetHeadPosition();
while (pos != NULL)
{
file = selectedList.GetNext(pos);
if (!str.IsEmpty())
str += _T("\r\n");
str += CreateED2kLink(file);
}
theApp.CopyTextToClipboard(str);
break;
}
// file operations
case MP_REMOVE:
case MPG_DELETE:{
if (IDNO == AfxMessageBox(GetResString(IDS_CONFIRM_FILEDELETE),MB_ICONWARNING | MB_ICONQUESTION | MB_DEFBUTTON2 | MB_YESNO))
return TRUE;
m_pSharedFilesCtrl->SetRedraw(FALSE);
bool bRemovedItems = false;
while (!selectedList.IsEmpty())
{
CKnownFile* myfile = selectedList.RemoveHead();
if (!myfile || myfile->IsPartFile())
continue;
BOOL delsucc = FALSE;
if (!PathFileExists(myfile->GetFilePath()))
delsucc = TRUE;
else{
// Delete
if (!thePrefs.GetRemoveToBin()){
delsucc = DeleteFile(myfile->GetFilePath());
}
else{
// delete to recycle bin :(
TCHAR todel[MAX_PATH+1];
memset(todel, 0, sizeof todel);
_tcsncpy(todel, myfile->GetFilePath(), ARRSIZE(todel)-2);
SHFILEOPSTRUCT fp = {0};
fp.wFunc = FO_DELETE;
fp.hwnd = theApp.emuledlg->m_hWnd;
fp.pFrom = todel;
fp.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION | FOF_SILENT;// | FOF_NOERRORUI
delsucc = (SHFileOperation(&fp) == 0);
}
}
if (delsucc){
theApp.sharedfiles->RemoveFile(myfile);
bRemovedItems = true;
if (myfile->IsKindOf(RUNTIME_CLASS(CPartFile)))
theApp.emuledlg->transferwnd->downloadlistctrl.ClearCompleted(static_cast<CPartFile*>(myfile));
}
else{
CString strError;
strError.Format( GetResString(IDS_ERR_DELFILE) + _T("\r\n\r\n%s"), myfile->GetFilePath(), GetErrorMessage(GetLastError()));
AfxMessageBox(strError);
//.........这里部分代码省略.........