Example #1
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, wchar_t* lpstrCmdLine, int nCmdShow){
  HRESULT hRes = ::OleInitialize(NULL);
  ::DefWindowProc(NULL, 0, 0, 0L);
  AtlInitCommonControls(ICC_BAR_CLASSES | ICC_DATE_CLASSES);//Add flags to support other controls
  hRes = _Module.Init(NULL, hInstance);
  int nRet = 0;

  wchar_t pszLoader[MAX_PATH];
  ::GetModuleFileName(NULL, pszLoader, MAX_PATH);
  CheckVersion(pszLoader);

  _6bees_socket::ftpclient ftpClient;
  _6bees_timer::CTimer m_Timer;

  //UPLOADERMODE mode;
  vector<wstring> vec_files;
  //ParseCmdline(stringmaker(CP_ACP)<<lpstrCmdLine,mode,&vec_files);
  if (lpstrCmdLine==NULL){

  }else if (_6bees_str::startwith<wstring>(lpstrCmdLine,L"-m upload ")){
    wstring cmdline(lpstrCmdLine);
    cmdline = cmdline.substr(10);
    vec_files = _6bees_util::Split(cmdline,L"|");
  }

  // 1. If there is an uploader already, then open it and upload
  HWND hwndTo = ::FindWindow(0,_6bees_const::kUploader_WndTitle);
  if(hwndTo){
    wstring filelist;//f will be like:XXX YYY ZZZ
    for(int i=0;i<(int)vec_files.size();i++){
      filelist.append(vec_files[i] + ((i==(int)vec_files.size()-1)?_T(""):_T("\t")));
    }
    SendMsgToUploader(hwndTo,(stringmaker()<<filelist).c_str(),CPYDATA_UPLOAD_2_UPLOAD);
  }else{
    // 2. open a new uploader
    CMainDlg dlgMain;
    int mssize=0;
    if(vec_files.empty()){
      CString strFolderPath,strFileName;
      dlgMain.PopDlgtoSelectFiles(strFolderPath,strFileName,mssize);
    }else{
      for(vector<wstring>::const_iterator i=vec_files.begin();i!=vec_files.end();++i){
        if(!PathIsDirectory(i->c_str()) && PathFileExists(i->c_str()) && GetFileSizeW(i->c_str(),mssize))
        {
          CFileProfile fileProfile(0,i->c_str(),mssize);
          dlgMain.AddUploadFile(fileProfile);
        }
      }
    }
    if(!dlgMain.IsEmpty())
      nRet = (int)dlgMain.DoModal();
  }
                     
  _Module.Term();
  ::OleUninitialize();
  return nRet;
}