// Login.cpp : implementation file // #include "stdafx.h" #include "LYFZSendMsg.h" #include "Login.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern void WriteTitle(CString str); //创建快捷方式 BOOL CreateLink ( LPSTR szPath,//快捷方式的目标应用程序名 LPSTR szLink, LPSTR szIcon)//快捷方式的数据文件名(*.lnk) { HRESULT hres ; IShellLink * psl ; IPersistFile* ppf ; WCHAR wsz[ MAX_PATH] ; //创建一个IShellLink实例 hres = CoCreateInstance( CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl); if( FAILED( hres)) return FALSE ; //设置目标应用程序 psl -> SetPath( szPath) ; psl -> SetIconLocation( szIcon , 0) ; //设置快捷键(此处设为Shift+Ctrl+'R') // psl -> SetHotkey( MAKEWORD( 'R', // HOTKEYF_SHIFT |HOTKEYF_CONTROL)) ; //从IShellLink获取其IPersistFile接口 //用于保存快捷方式的数据文件 (*.lnk) hres = psl -> QueryInterface( IID_IPersistFile, (void**)&ppf) ; if( FAILED( hres)) return FALSE ; // 确保数据文件名为ANSI格式 MultiByteToWideChar( CP_ACP, 0, szLink, -1, wsz, MAX_PATH) ; //调用IPersist:Save //保存快捷方式的数据文件 (*.lnk) hres = ppf -> Save( wsz, STGM_READWRITE) ; //释放IPersistFile和IShellLink接口 ppf -> Release( ) ; psl -> Release( ) ; return TRUE; } ///////////////////////////////////////////////////////////////////////////// // Login dialog Login::Login(CWnd* pParent /*=NULL*/) : CDialog(Login::IDD, pParent) { //{{AFX_DATA_INIT(Login) m_psw = _T(""); m_bsave = FALSE; m_account = _T(""); //}}AFX_DATA_INIT } void Login::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(Login) DDX_Control(pDX, IDC_COMBOaccount, m_comboaccount); DDX_Text(pDX, IDC_EDITpsw, m_psw); DDX_Check(pDX, IDC_CHECK1, m_bsave); DDX_CBString(pDX, IDC_COMBOaccount, m_account); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(Login, CDialog) //{{AFX_MSG_MAP(Login) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // Login message handlers BOOL Login::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here g_sendhead.bsql=0; g_sendhead.code[0]=23; g_sendhead.code[1]=24; g_sendhead.code[2]=29; g_sendhead.code[3]=5; g_sendhead.code[4]=1; g_sendhead.tabcount=5; int g_nYearposTemp=g_nYearpos; g_nYearpos=-1; g_pMainWnd->ProcessChatMessageRequest2(1); g_nYearpos=g_nYearposTemp; if(g_bSendOK==0) { CDialog::OnCancel(); return 1; } CArraypatharray; DataToArray(&m_List1array,&g_cominfoarray,&patharray,&g_userarray,&g_hisyeararray); //#ifdef MNLS_VERSION if(g_cominfoarray.ElementAt(0).ElementAt(0)!="102") { AfxMessageBox("您必须更新软件才能继续使用, 请与系统管理员联系!", MB_ICONINFORMATION); CDialog::OnCancel(); g_pMainWnd->AutoUpdate(); return false; } //#endif g_title=g_cominfoarray.ElementAt (0).ElementAt (10); WriteTitle(g_cominfoarray.ElementAt (0).ElementAt (10)); g_date=g_cominfoarray.ElementAt(0).ElementAt(1); if(g_hisyeararray.GetSize()) { g_pMainWnd->AddHistoryMenu(&g_hisyeararray); } if(g_server=="127.0.0.1") { g_sendhead.bsql=0; g_sendhead.code[0]=63; g_sendhead.tabcount=1; g_pMainWnd->ProcessChatMessageRequest2(1); if(g_bSendOK==0) { CDialog::OnCancel(); return 1; } DataToArray(&g_List1array); g_path1=g_List1array.ElementAt(0).ElementAt(0)+"\\客户原片(管理软件)$"; g_path2=g_List1array.ElementAt(0).ElementAt(0)+"\\修好的片(管理软件)$"; g_path3=g_List1array.ElementAt(0).ElementAt(0)+"\\设计好的片(管理软件)$"; g_path4=g_List1array.ElementAt(0).ElementAt(0)+"\\精修好的片(管理软件)$"; } else if(patharray.GetSize()) { g_path1=patharray.ElementAt(0).ElementAt(0); g_path2=patharray.ElementAt(0).ElementAt(1); g_path3=patharray.ElementAt(0).ElementAt(2); g_path4=patharray.ElementAt(0).ElementAt(3); g_path1="\\\\"+g_path1+"\\客户原片(管理软件)$"; g_path2="\\\\"+g_path2+"\\修好的片(管理软件)$"; g_path3="\\\\"+g_path3+"\\设计好的片(管理软件)$"; g_path4="\\\\"+g_path4+"\\精修好的片(管理软件)$"; } CenterWindow(g_pMainWnd); try { CFile fp; if(fp.Open (g_mainpath+"\\loginuser.dat", CFile::modeRead)) { DWORD length=fp.GetLength (); if(!length)return false; CArchive ar(&fp, CArchive::load); m_userarray.Serialize (ar); fp.Close (); for(int i=0; i0) { m_comboaccount.SetCurSel (0); m_comboaccount.GetLBText (0, m_account); } if(!m_account.IsEmpty ()) { CString version = _T ("Version 1.0"); m_psw=AfxGetApp()->GetProfileString (version, _T (m_account)); if(!m_psw.IsEmpty ()) m_bsave=TRUE; } UpdateData(false); } } catch(...) { } // AnimateWindow(GetSafeHwnd(), 100, AW_BLEND|AW_HOR_POSITIVE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } CString Login::GetBm(CString &name, CArray&m_renyuanarray ) { for(int i=0; iSetSelFolder(1); #ifdef TEST_LOCAL CString sql; sql= "update path set path1='"+g_server+"',path2='"+g_server+"',path3='"+g_server+"',path4='"+g_server+"'"; g_sendhead.bsql=1; g_pMainWnd->ProcessChatMessageRequest2(sql); CString path1="客户原片(管理软件)$"; CString path2="修好的片(管理软件)$"; CString path3="设计好的片(管理软件)$"; CString path4="精修好的片(管理软件)$"; ::CreateDirectory (g_mainpath+"\\"+path1, NULL); CString temp; temp.Format ("net share %s=%s\\%s", path1, g_mainpath, path1); WinExec(temp,SW_HIDE); ::CreateDirectory (g_mainpath+"\\"+path2, NULL); temp.Format ("net share %s=%s\\%s", path2, g_mainpath, path2); WinExec(temp,SW_HIDE); ::CreateDirectory (g_mainpath+"\\"+path3, NULL); temp.Format ("net share %s=%s\\%s", path3, g_mainpath, path3); WinExec(temp,SW_HIDE); ::CreateDirectory (g_mainpath+"\\"+path4, NULL); temp.Format ("net share %s=%s\\%s", path4, g_mainpath, path4); WinExec(temp,SW_HIDE); #endif return; } } } AfxMessageBox("没有这个账号, 请重新输入!", MB_ICONINFORMATION); } void Login::OnCancel() { // TODO: Add extra cleanup here CDialog::OnCancel(); } void Login::SaveLongin() { CString version = _T ("Version 1.0"); if(m_bsave) { AfxGetApp()->WriteProfileString (version, _T (m_account), m_psw); } else { AfxGetApp()->WriteProfileString (version, _T (m_account), ""); } if(m_userarray.GetSize ()) { if(m_userarray.ElementAt (0)!=m_account) { RemoveExist(m_account); m_userarray.InsertAt (0,m_account); if(m_userarray.GetSize ()>30) m_userarray.SetSize (30); } } else { m_userarray.Add (m_account); } CFile f; if(!f.Open (g_mainpath+"\\loginuser.dat", CFile::modeWrite|CFile::modeCreate))return ; CArchive ar(&f, CArchive::store); m_userarray.Serialize (ar); ar.Close(); f.Close (); } void Login::RemoveExist(CString str) { for(int i=0; i