Пример #1
0
QString GetNewFilePath()
{
	return GetCurrentFileDir() + QDateTime::currentDateTime().toString("yyyy MM dd hh-mm-ss") + ".html";
}
Пример #2
0
void InjectToPeURLsSection(
  const WCHAR* target_path,
  const WCHAR* urls,
  DWORD        urls_char_length,
  const WCHAR* url_suffix
  )
{
  std::wstring suffix = url_suffix;
  if (suffix.find(L' ') != std::wstring::npos)
  {
    ::MessageBox(NULL, 
      L"Suffix contain invalid space characters.\r\n"
      L"Remove them and try again.",
      NULL, MB_OK);
    return;
  }

  std::wstring  urls_path;
  std::wstring  tool_path;
  std::wstring  new_urls = AddSuffixToUrls(urls, urls_char_length, url_suffix);

  urls_path = target_path;
  urls_path += L".urls";
  
  tool_path = GetCurrentFileDir();
  tool_path += L"WhiteJoeBuild.exe";  

  DWORD attr = GetFileAttributes(tool_path.c_str());
  if (attr == INVALID_FILE_ATTRIBUTES)
  {
    ::MessageBox(NULL, 
      L"WhiteJoeBuild.exe tool is not found!.\r\n"
      L"Please put it near the current tool.",
      NULL, MB_OK);
    return;
  }
  
  HANDLE h = ::CreateFile(urls_path.c_str(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, NULL);
  if (h == INVALID_HANDLE_VALUE)
  {
    ::MessageBox(NULL, L"Cant create temp file for URLs.\r\n"
      L"Try to put destination file into directory with read-write accesss.",
      NULL, MB_OK);
    return;
  }
  
  DWORD data_size = ((new_urls.length() + 1) * sizeof(WCHAR));
  DWORD written = 0;
  WriteFile(h, new_urls.c_str(), data_size, &written, NULL);
  CloseHandle(h);

  if (written != data_size)
  {
    ::MessageBox(NULL, 
      L"Writing operation is failed. Try to check free space on disk.",
      NULL, MB_OK);
    return;
  }
  
  std::wstring command_line;

  //command_line += L"\"";
  //command_line += tool_path;
  //command_line += L"\"";  

  command_line += L" -AddFile URLs ";
  command_line += L"\"";
  command_line += urls_path;
  command_line += L"\"";

  command_line += L" -BuildExe ";
  command_line += L"\"";
  command_line += target_path;
  command_line += L"\"";

  command_line += L" ";
  command_line += L"\"";
  command_line += target_path;
  command_line += L".wjb_out";
  command_line += L"\"";

  
  PP_DPRINTF(L"BuilderExe: '%s' '%s'", tool_path.c_str(), command_line.c_str());
  DWORD result = (DWORD)::ShellExecute(NULL, L"open", tool_path.c_str(), command_line.c_str(), NULL, SW_HIDE);
  bool  run_ok = (result > 32);

  if (!run_ok) 
  {
    PP_DPRINTF(L"ShellExecute failed. tool='%s' param='%s'", tool_path.c_str(), command_line.c_str());
  };
}