00001 /* 00002 Free Download Manager Copyright (c) 2003-2007 FreeDownloadManager.ORG 00003 Open Download Manager Copyright (c) 2008-2010 OpenDownloadManager.ORG 00004 */ 00005 00006 #include "stdafx.h" 00007 #include "FdmApp.h" 00008 #include "vmsTorrentExtension.h" 00009 #include "vmsFileExtensionInOs.h" 00010 00011 #ifdef _DEBUG 00012 #undef THIS_FILE 00013 static char THIS_FILE[]=__FILE__; 00014 #define new DEBUG_NEW 00015 #endif 00016 00017 vmsTorrentExtension::vmsTorrentExtension() 00018 { 00019 00020 } 00021 00022 vmsTorrentExtension::~vmsTorrentExtension() 00023 { 00024 00025 } 00026 00027 BOOL vmsTorrentExtension::Associate() 00028 { 00029 return AssociateWith (get_ShellOpenCommandLine ()); 00030 } 00031 00032 fsString vmsTorrentExtension::get_ShellOpenCommandLine() 00033 { 00034 fsString str = "\""; 00035 str += ((CFdmApp*)AfxGetApp ())->m_strAppPath; 00036 if (str [str.GetLength () - 1] != '\\') 00037 str += '\\'; 00038 str += "fdm.exe\" \"%1\""; 00039 return str; 00040 } 00041 00042 BOOL vmsTorrentExtension::IsAssociationExist() 00043 { 00044 return GetCurrentAssociation ().IsEmpty () == FALSE; 00045 } 00046 00047 BOOL vmsTorrentExtension::IsAssociatedWithUs() 00048 { 00049 return stricmp (vmsFileExtensionInOs::GetAssociation ("torrent", "open"), 00050 get_ShellOpenCommandLine ()) == 0; 00051 } 00052 00053 fsString vmsTorrentExtension::GetCurrentAssociation() 00054 { 00055 return vmsFileExtensionInOs::GetAssociation ("torrent", "open"); 00056 } 00057 00058 BOOL vmsTorrentExtension::AssociateWith(LPCSTR pszCmdLine) 00059 { 00060 if (pszCmdLine && *pszCmdLine) 00061 { 00062 return vmsFileExtensionInOs::SetAssociation ("torrent", "open", pszCmdLine); 00063 } 00064 else 00065 { 00066 CRegKey key; 00067 if (ERROR_SUCCESS != key.Open (HKEY_CLASSES_ROOT, "")) 00068 return FALSE; 00069 return ERROR_SUCCESS == key.RecurseDeleteKey (".torrent"); 00070 } 00071 } 00072
1.5.6