Beispiel #1
0
CString FileMisc::GetAppFolder(LPCTSTR szSubFolder)
{
	CString sFolder = GetModuleFolder();

	if (szSubFolder && *szSubFolder)
	{
		MakePath(sFolder, NULL, sFolder, szSubFolder, NULL);
	}

	return UnterminatePath(sFolder);
}
Beispiel #2
0
void SkinDownload::_Thread()
{
/*
  refptr<request> req = request::create_instance();

  req->set_request_url(m_url.c_str());
  req->set_request_method(REQ_GET);

  if (req->get_response_errcode() != 0)
    return;

  si_buffer buffer = req->get_response_buffer();
  buffer.push_back(0);

  std::string results = (char*)&buffer[0];
  std::wstring retdata = Strings::Utf8StringToWString(results);*/

  HINTERNET hi=InternetOpen(L"http_down_dll",INTERNET_OPEN_TYPE_PRECONFIG,NULL,INTERNET_INVALID_PORT_NUMBER,0);
  if(hi==NULL)
  {
    return;
  }
  /*HINTERNET hUrl=InternetOpenUrl(hi,retdata.c_str(),NULL,0,INTERNET_FLAG_RELOAD,0);*/
  HINTERNET hUrl=InternetOpenUrl(hi,m_url.c_str(),NULL,0,INTERNET_FLAG_RELOAD,0);

  if(hUrl==NULL)
  {
    InternetCloseHandle(hi);
    return;
  }
  DWORD optbuf[256]={0};
  DWORD optlen=256;
  if(HttpQueryInfo(hUrl,HTTP_QUERY_CONTENT_LENGTH,optbuf,&optlen,NULL)==FALSE)
  {
    InternetCloseHandle(hUrl);
    InternetCloseHandle(hi);
    return;
  }
  char tmpbuff[256]={0};
  sprintf(tmpbuff,"%s",optbuf);
  long flen=atol(tmpbuff);
  if(flen<=0)
  {
    InternetCloseHandle(hUrl);
    InternetCloseHandle(hi);
    return;
  }

  std::wstring savepath = GetModuleFolder();
  savepath += L"skins\\";
  BOOL bl = CreateDirectory(savepath.c_str(), 0);
  if (bl == ERROR_PATH_NOT_FOUND)
    return;
  savepath += m_filename;
  HANDLE hFile=CreateFile(savepath.c_str(),GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
  if(hFile==NULL)
  {
    InternetCloseHandle(hUrl);
    InternetCloseHandle(hi);
    return;
  }

  BYTE bufferstr[1024]={0};
  DWORD len=0,wlen=0;
  DWORD wsum=0;
  long sendlen=flen;

  while(InternetReadFile(hUrl,(LPVOID)bufferstr,1024,&len)&&len!=0)
    WriteFile(hFile,bufferstr,len,&wlen,NULL);
     
  CloseHandle(hFile);
  InternetCloseHandle(hUrl);
  InternetCloseHandle(hi);
  
  TCHAR szModuleFullPath[MAX_PATH];
  ::GetModuleFileName(0, szModuleFullPath, MAX_PATH);
  TCHAR szDrive[10] = {0};
  TCHAR szDir[MAX_PATH] = {0};
  ::_wsplitpath(szModuleFullPath, szDrive, szDir, 0, 0);
  CString skinpath;
  skinpath += szDrive;
  skinpath += szDir;
  skinpath += L"skins\\";
  SkinFolderManager skmn;
  skmn.ClearMap();
  skmn.SetSkinPath(skinpath);
  skmn.SeachFile(skinpath.GetBuffer(MAX_PATH));
  skinpath.ReleaseBuffer();
  ::SendMessage(GetParent()->m_hWnd, WM_USER + 34, 0, 0);

  HideFrame();

}