FtpPublic.cpp
上传用户:maryhy001
上传日期:2007-05-02
资源大小:2317k
文件大小:3k
- #include "stdAfx.h"
- #include "FtpPublic.h"
- //get all ftp profile names list.
- BOOL GetAllFtpProfileNames(CStringList &oProfileNamesList)
- {
- CRegister regKey;
- //open ftp root key.
- if(!regKey.Open(HKEY_CURRENT_USER, REG_SFTPSEETINGKEY))
- {
- TRACE0("Failed to open the ftp registry root keyn");
- return FALSE;
- }
- return regKey.EnumSubKeyNames(oProfileNamesList);
- }
- //get the ftp setting from profile name.
- BOOL GetFtpSiteInfo(LPCSTR szProfileName, CFtpSite &oFtpSite)
- {
- CRegister regKey;
-
- //get the profile path in the registry.
- CString strkeypath;
- strkeypath.Format("%s\%s", REG_SFTPSEETINGKEY, szProfileName);
-
- //open ftp root key.
- if(!regKey.KeyExists(HKEY_CURRENT_USER, strkeypath.GetBuffer(0)))
- {
- TRACE0("Specialed ftp registry key doesn't existn");
- return FALSE;
- }
- if(!regKey.Open(HKEY_CURRENT_USER, strkeypath.GetBuffer(0)))
- {
- TRACE0("Failed to open the ftp someone profile registry keyn");
- return FALSE;
- }
- oFtpSite.m_bPASVMode = regKey.Read_Bool_Value(REG_BFTPPASVMODE);
- oFtpSite.m_bAnonymous = regKey.Read_Bool_Value(REG_BFTPANONYMOUS);
-
- oFtpSite.m_sProfile = szProfileName;
- oFtpSite.m_sHost = regKey.Read_String_Value(REG_SFTPHOSTNAME);
- oFtpSite.m_nPort = regKey.Read_DWord_Value(REG_SFTPPORT);
- oFtpSite.m_sUser = regKey.Read_String_Value(REG_SFTPUSERNAME);
- oFtpSite.m_sPassword = regKey.Read_String_Value(REG_SFTPPASSWORD);
- oFtpSite.m_sDowntoDir = regKey.Read_String_Value(REG_SFTPDOWNTODIR);
- oFtpSite.m_sDescription= regKey.Read_String_Value(REG_SFTPDESCRIPTION);
-
- return TRUE;
- }
- //add one ftp site setting into the registry.
- BOOL AddFtpSiteInfo(CFtpSite &oFtpSite)
- {
- CRegister regKey;
-
- //get the profile path in the registry.
- CString strkeypath;
- strkeypath.Format("%s\%s", REG_SFTPSEETINGKEY, oFtpSite.m_sProfile);
- //open | new ftp setting root key.
- if(!regKey.Open(HKEY_CURRENT_USER, strkeypath.GetBuffer(0)))
- {
- TRACE0("Failed to open the ftp someone profile registry keyn");
- return FALSE;
- }
- BOOL bret = regKey.Write_Bool_Value(REG_BFTPPASVMODE, oFtpSite.m_bPASVMode);
- bret = bret && regKey.Write_Bool_Value(REG_BFTPANONYMOUS, oFtpSite.m_bAnonymous);
- bret = bret && regKey.Write_String_Value(REG_SFTPHOSTNAME, oFtpSite.m_sHost);
- bret = bret && regKey.Write_DWord_Value(REG_SFTPPORT, oFtpSite.m_nPort);
- bret = bret && regKey.Write_String_Value(REG_SFTPUSERNAME, oFtpSite.m_sUser);
- bret = bret && regKey.Write_String_Value(REG_SFTPPASSWORD, oFtpSite.m_sPassword);
- bret = bret && regKey.Write_String_Value(REG_SFTPDOWNTODIR, oFtpSite.m_sDowntoDir);
- bret = bret && regKey.Write_String_Value(REG_SFTPDESCRIPTION, oFtpSite.m_sDescription);
- return bret;
- }
- //delete one existing ftp site setting from the registry.
- BOOL RemoveFtpSiteInfo(LPCSTR szProfileName)
- {
- CRegister regKey;
-
- //get the profile path in the registry.
- CString strkeypath;
- strkeypath.Format("%s\%s", REG_SFTPSEETINGKEY, szProfileName);
- //open ftp root key.
- if(!regKey.KeyExists(HKEY_CURRENT_USER, strkeypath.GetBuffer(0)))
- {
- TRACE0("Specialed ftp registry key doesn't existn");
- return FALSE;
- }
- //open ftp setting root key.
- if(!regKey.Open(HKEY_CURRENT_USER, REG_SFTPSEETINGKEY))
- {
- TRACE0("Failed to open the ftp someone profile registry keyn");
- return FALSE;
- }
- return regKey.DeleteSubKey(szProfileName);
- }