コード例 #1
1
ファイル: File.cpp プロジェクト: donbex/spkutils
bool LZMADecodeFile ( const char *fromFile, const char *toFile, CProgressInfo7Zip *progress )
{
	CMyComPtr<ISequentialInStream> inStream;
	CInFileStream *inStreamSpec = new CInFileStream;
	inStream = inStreamSpec;

	if ( !inStreamSpec->Open ( GetSystemString(fromFile) ) )
		return false;

	CMyComPtr<ISequentialOutStream> outStream;
	COutFileStream *outStreamSpec = new COutFileStream;
	outStream = outStreamSpec;
	if ( !outStreamSpec->Create ( GetSystemString(toFile), true ) )
		return false;


	NCompress::NLZMA::CDecoder *decoderSpec = new NCompress::NLZMA::CDecoder;

	CMyComPtr<ICompressCoder> decoder = decoderSpec;

	const UInt32 kPropertiesSize = 5;
	Byte properties[kPropertiesSize];
	UInt32 processedSize;
	
	if ( ReadStream (inStream, properties, kPropertiesSize, &processedSize) != S_OK )
		return false;

	if ( processedSize != kPropertiesSize )
		return false;

	if ( decoderSpec->SetDecoderProperties2(properties, kPropertiesSize) != S_OK )
		return false;

	UInt64 fileSize = 0;
	for (int i = 0; i < 8; i++)
	{
	  Byte b;
	  if ( inStream->Read(&b, 1, &processedSize) != S_OK )
		  return false;

	  if ( processedSize != 1 )
		  return false;
	  fileSize |= ((UInt64)b) << (8 * i);
	}

	if ( progress )
	{
		progress->Init();
		progress->ApprovedStart = 1 << 21;
		progress->SetMax ( fileSize );
	}

	if ( decoder->Code(inStream, outStream, 0, &fileSize, progress) != S_OK )
		// decoder error
		return false;

	return true;
}
コード例 #2
0
ファイル: Window.cpp プロジェクト: BIAINC/7Zip
bool CWindow::CreateEx(DWORD exStyle, LPCWSTR className,
      LPCWSTR windowName, DWORD style,
      int x, int y, int width, int height,
      HWND parentWindow, HMENU idOrHMenu,
      HINSTANCE instance, LPVOID createParam)
{
  if (g_IsNT)
  {
    _window = ::CreateWindowExW(exStyle, className, windowName,
      style, x, y, width, height, parentWindow,
      idOrHMenu, instance, createParam);
     return (_window != NULL);
  }
  AString classNameA;
  LPCSTR classNameP;
  if (IS_INTRESOURCE(className))
    classNameP = (LPCSTR)className;
  else
  {
    classNameA = GetSystemString(className);
    classNameP = classNameA;
  }
  AString windowNameA;
  LPCSTR windowNameP;
  if (IS_INTRESOURCE(windowName))
    windowNameP = (LPCSTR)windowName;
  else
  {
    windowNameA = GetSystemString(windowName);
    windowNameP = windowNameA;
  }
  return CreateEx(exStyle, classNameP, windowNameP,
      style, x, y, width, height, parentWindow,
      idOrHMenu, instance, createParam);
}
コード例 #3
0
ファイル: Window.cpp プロジェクト: BIAINC/7Zip
ATOM MyRegisterClass(CONST WNDCLASSW *wndClass)
{
  if (g_IsNT)
    return RegisterClassW(wndClass);
  WNDCLASSA wndClassA;
  wndClassA.style = wndClass->style;
  wndClassA.lpfnWndProc = wndClass->lpfnWndProc;
  wndClassA.cbClsExtra = wndClass->cbClsExtra;
  wndClassA.cbWndExtra = wndClass->cbWndExtra;
  wndClassA.hInstance = wndClass->hInstance;
  wndClassA.hIcon = wndClass->hIcon;
  wndClassA.hCursor = wndClass->hCursor;
  wndClassA.hbrBackground = wndClass->hbrBackground;
  AString menuName;
  AString className;
  if (IS_INTRESOURCE(wndClass->lpszMenuName))
    wndClassA.lpszMenuName = (LPCSTR)wndClass->lpszMenuName;
  else
  {
    menuName = GetSystemString(wndClass->lpszMenuName);
    wndClassA.lpszMenuName = menuName;
  }
  if (IS_INTRESOURCE(wndClass->lpszClassName))
    wndClassA.lpszClassName = (LPCSTR)wndClass->lpszClassName;
  else
  {
    className = GetSystemString(wndClass->lpszClassName);
    wndClassA.lpszClassName = className;
  }
  return RegisterClassA(&wndClassA);
}
コード例 #4
0
ファイル: Net.cpp プロジェクト: BIAINC/7Zip
static void ConvertResourceWToResource(const CResourceW &resourceW, CResource &resource)
{
  *(CResourceBase *)&resource = *(CResourceBase *)&resourceW;
  resource.LocalName = GetSystemString(resourceW.LocalName);
  resource.RemoteName = GetSystemString(resourceW.RemoteName);
  resource.Comment = GetSystemString(resourceW.Comment);
  resource.Provider = GetSystemString(resourceW.Provider);
}
コード例 #5
0
ファイル: LangPage.cpp プロジェクト: StephanBusch/EcoZip
BOOL CLangPage::OnInitDialog()
{
  CPropertyPage::OnInitDialog();

  LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs));

  UString temp = NWindows::MyLoadString(IDS_LANG_ENGLISH);
  NativeLangString(temp, NWindows::MyLoadString(IDS_LANG_NATIVE));
  int index = (int)m_cmbLang.AddString(GetSystemString(temp));
  m_cmbLang.SetItemData(index, _paths.Size());
  _paths.Add(L"-");
  m_cmbLang.SetCurSel(0);

  const FString dirPrefix = GetLangDirPrefix();
  NWindows::NFile::NFind::CEnumerator enumerator(dirPrefix + FTEXT("*.txt"));
  NWindows::NFile::NFind::CFileInfo fi;
  CLang lang;
  UString error;

  while (enumerator.Next(fi))
  {
    if (fi.IsDir())
      continue;
    const int kExtSize = 4;
    if (fi.Name.Len() < kExtSize)
      continue;
    unsigned pos = fi.Name.Len() - kExtSize;
    if (!StringsAreEqualNoCase_Ascii(fi.Name.Ptr(pos), ".txt"))
      continue;

    if (!LangOpen(lang, dirPrefix + fi.Name))
    {
      error.Add_Space_if_NotEmpty();
      error += fs2us(fi.Name);
      continue;
    }

    const UString shortName = fs2us(fi.Name.Left(pos));
    UString s = shortName;
    const wchar_t *eng = lang.Get(IDS_LANG_ENGLISH);
    if (eng)
      s = eng;
    const wchar_t *native = lang.Get(IDS_LANG_NATIVE);
    if (native)
      NativeLangString(s, native);
    index = (int)m_cmbLang.AddString(GetSystemString(s));
    m_cmbLang.SetItemData(index, _paths.Size());
    _paths.Add(shortName);
    if (g_LangID.IsEqualTo_NoCase(shortName))
      m_cmbLang.SetCurSel(index);
  }

  if (!error.IsEmpty())
    ::MessageBoxW(m_hWnd, error, L"Error in Lang file", MB_ICONERROR);

  return TRUE;  // return TRUE unless you set the focus to a control
  // EXCEPTION: OCX Property Pages should return FALSE
}
コード例 #6
0
ファイル: Registry.cpp プロジェクト: headupinclouds/lzma-sdk
LONG CKey::SetValue(LPCWSTR name, LPCWSTR value)
{
  MYASSERT(value != NULL);
  MYASSERT(_object != NULL);
  if (g_IsNT)
    return RegSetValueExW(_object, name, NULL, REG_SZ,
      (const BYTE * )value, (DWORD)((wcslen(value) + 1) * sizeof(wchar_t)));
  return SetValue(name == 0 ? 0 : (LPCSTR)GetSystemString(name),
    value == 0 ? 0 : (LPCSTR)GetSystemString(value));
}
コード例 #7
0
WRes CProcess::Create(LPCWSTR imageName, const UString &params, LPCWSTR curDir)
{
  Close();
  const UString params2 =
      #ifndef UNDER_CE
      GetQuotedString(imageName) + L' ' +
      #endif
      params;
  #ifdef UNDER_CE
  curDir = 0;
  #else
  imageName = 0;
  #endif
  PROCESS_INFORMATION pi;
  BOOL result;
  #ifndef _UNICODE
  if (!g_IsNT)
  {
    STARTUPINFOA si;
    si.cb = sizeof(si);
    si.lpReserved = 0;
    si.lpDesktop = 0;
    si.lpTitle = 0;
    si.dwFlags = 0;
    si.cbReserved2 = 0;
    si.lpReserved2 = 0;
    
    CSysString curDirA;
    if (curDir != 0)
      curDirA = GetSystemString(curDir);
    result = ::CreateProcessA(NULL, (LPSTR)(LPCSTR)GetSystemString(params2),
        NULL, NULL, FALSE, 0, NULL, ((curDir != 0) ? (LPCSTR)curDirA: 0), &si, &pi);
  }
  else
  #endif
  {
    STARTUPINFOW si;
    si.cb = sizeof(si);
    si.lpReserved = 0;
    si.lpDesktop = 0;
    si.lpTitle = 0;
    si.dwFlags = 0;
    si.cbReserved2 = 0;
    si.lpReserved2 = 0;
    
    result = CreateProcessW(imageName, (LPWSTR)(LPCWSTR)params2,
        NULL, NULL, FALSE, 0, NULL, (LPWSTR)curDir, &si, &pi);
  }
  if (result == 0)
    return ::GetLastError();
  ::CloseHandle(pi.hThread);
  _handle = pi.hProcess;
  return 0;
}
コード例 #8
0
ファイル: Registry.cpp プロジェクト: headupinclouds/lzma-sdk
LONG CKey::DeleteValue(LPCWSTR name)
{
  MYASSERT(_object != NULL);
  if (g_IsNT)
    return ::RegDeleteValueW(_object, name);
  return DeleteValue(name == 0 ? 0 : (LPCSTR)GetSystemString(name));
}
コード例 #9
0
ファイル: FileSystem.cpp プロジェクト: BIAINC/7Zip
bool MyGetVolumeInformation(
    LPCWSTR rootPathName,
    UString &volumeName,
    LPDWORD volumeSerialNumber,
    LPDWORD maximumComponentLength,
    LPDWORD fileSystemFlags,
    UString &fileSystemName)
{
  if (g_IsNT)
  {
    bool result = BOOLToBool(GetVolumeInformationW(
      rootPathName,
      volumeName.GetBuffer(MAX_PATH), MAX_PATH,
      volumeSerialNumber,
      maximumComponentLength,
      fileSystemFlags,
      fileSystemName.GetBuffer(MAX_PATH), MAX_PATH));
    volumeName.ReleaseBuffer();
    fileSystemName.ReleaseBuffer();
    return result;
  }
  AString volumeNameA, fileSystemNameA;
  bool result = MyGetVolumeInformation(GetSystemString(rootPathName), volumeNameA,
      volumeSerialNumber, maximumComponentLength, fileSystemFlags,fileSystemNameA);
  if (result)
  {
    volumeName = GetUnicodeString(volumeNameA);
    fileSystemName = GetUnicodeString(fileSystemNameA);
  }
  return result;
}
コード例 #10
0
ファイル: Shell.cpp プロジェクト: Ando02/wubiuefi
bool BrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath)
{
  if (g_IsNT)
    return BrowseForFolder(owner, title, 
      BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS 
      //  | BIF_STATUSTEXT // This flag is not supported when BIF_NEWDIALOGSTYLE is specified.
      , initialFolder, resultPath);
  // BIF_STATUSTEXT; BIF_USENEWUI   (Version 5.0)
  CSysString s;
  bool res = BrowseForFolder(owner, GetSystemString(title), 
      BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS 
      // | BIF_STATUSTEXT  // This flag is not supported when BIF_NEWDIALOGSTYLE is specified.
      , GetSystemString(initialFolder), s); 
  resultPath = GetUnicodeString(s);
  return res;
}
コード例 #11
0
ファイル: OverwriteDialog.cpp プロジェクト: bks/qz7
void SetFileInfoStrings(const CFileInfo &fileInfo,
    CFileInfoStrings &fileInfoStrings)
{
  char buffer[256];

  if (fileInfo.SizeIsDefined)
  {
    sprintf(buffer, "%I64u ", fileInfo.Size);
    fileInfoStrings.Size = buffer;
    fileInfoStrings.Size += g_StartupInfo.GetMsgString(NMessageID::kOverwriteBytes);
  }
  else
  {
    fileInfoStrings.Size = "";
  }

  FILETIME localFileTime;
  fileInfoStrings.Time.Empty();
  if (fileInfo.TimeIsDefined)
  {
    if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
      throw 4190402;
    UString timeString = ConvertFileTimeToString(localFileTime);
    fileInfoStrings.Time = g_StartupInfo.GetMsgString(NMessageID::kOverwriteModifiedOn);
    fileInfoStrings.Time += " ";
    fileInfoStrings.Time += GetSystemString(timeString, CP_OEMCP);
  }
}
コード例 #12
0
ファイル: Menu.cpp プロジェクト: bks/qz7
bool CMenu::AppendItem(UINT flags, UINT_PTR newItemID, LPCWSTR newItem)
{
  if (g_IsNT)
    return BOOLToBool(::AppendMenuW(_menu, flags, newItemID, newItem));
  else
    return AppendItem(flags, newItemID, GetSystemString(newItem));
}
コード例 #13
0
ファイル: Menu.cpp プロジェクト: bks/qz7
bool CMenu::InsertItem(UINT itemIndex, bool byPosition, const CMenuItem &item)
{
  #ifndef _UNICODE
  if (!g_IsNT)
  {
    MENUITEMINFOA si;
    ConvertItemToSysForm(item, si);
    AString s;
    if (item.IsString())
    {
      s = GetSystemString(item.StringValue);
      si.dwTypeData = (LPTSTR)(LPCTSTR)s;
    }
    return InsertItem(itemIndex, byPosition, &si);
  }
  else
  #endif
  {
    MENUITEMINFOW si;
    ConvertItemToSysForm(item, si);
    if (item.IsString())
      si.dwTypeData = (LPWSTR)(LPCWSTR)item.StringValue;
    return InsertItem(itemIndex, byPosition, &si);
  }
}
コード例 #14
0
ファイル: Net.cpp プロジェクト: BIAINC/7Zip
DWORD AddConnection2(const CResourceW &resource, LPCWSTR password, LPCWSTR userName, DWORD flags)
{
  if (g_IsNT)
  {
    NETRESOURCEW netResource;
    ConvertCResourceToNETRESOURCE(resource, netResource);
    return ::WNetAddConnection2W(&netResource,password, userName, flags);
  }
  CResource resourceA;
  ConvertResourceWToResource(resource, resourceA);
  CSysString passwordA = GetSystemString(password);
  CSysString userNameA = GetSystemString(userName);
  return AddConnection2(resourceA,
    password ? (LPCTSTR)passwordA: 0,
    userName ? (LPCTSTR)userNameA: 0,
    flags);
}
コード例 #15
0
ファイル: Window.cpp プロジェクト: BIAINC/7Zip
bool CWindow::Create(LPCWSTR className,
      LPCWSTR windowName, DWORD style,
      int x, int y, int width, int height,
      HWND parentWindow, HMENU idOrHMenu,
      HINSTANCE instance, LPVOID createParam)
{
  if (g_IsNT)
  {
    _window = ::CreateWindowW(className, windowName,
        style, x, y, width, height, parentWindow,
        idOrHMenu, instance, createParam);
     return (_window != NULL);
  }
  return Create(GetSystemString(className), GetSystemString(windowName),
        style, x, y, width, height, parentWindow,
        idOrHMenu, instance, createParam);
}
コード例 #16
0
ファイル: FarUtils.cpp プロジェクト: Esika/sevenzipjbinding
void CStartupInfo::Init(const PluginStartupInfo &pluginStartupInfo,
    const CSysString &pluginNameForRegestry)
{
  m_Data = pluginStartupInfo;
  m_RegistryPath = GetSystemString(pluginStartupInfo.RootKey);
  m_RegistryPath += TEXT('\\');
  m_RegistryPath += pluginNameForRegestry;
}
コード例 #17
0
ファイル: HelpUtils.cpp プロジェクト: Ando02/wubiuefi
void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile)
{
  UString path;
  if (!::GetProgramFolderPath(path))
    return;
  path += kHelpFileName;
  path += topicFile;
  HtmlHelp(hwnd, GetSystemString(path), HH_DISPLAY_TOPIC, NULL);
}
コード例 #18
0
ファイル: RegistryAssociations.cpp プロジェクト: BIAINC/7Zip
bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo)
{
  NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
  CKey key;
  if (key.Open(HKEY_CURRENT_USER,
      CSysString(kAssociationsPath TEXT(STRING_PATH_SEPARATOR)) +
      GetSystemString(ext), KEY_READ) != ERROR_SUCCESS)
    return false;
  UString pluginsString;
  key.QueryValue(kExtPlugins, pluginsString);
  SplitString(pluginsString, extInfo.Plugins);
  return true;
}
コード例 #19
0
ファイル: Dialog.cpp プロジェクト: Alexander-r/physfs
INT_PTR CModalDialog::Create(LPCWSTR templateName, HWND parentWindow)
{
  if (g_IsNT)
    return DialogBoxParamW(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
  AString name;
  LPCSTR templateNameA;
  if (IS_INTRESOURCE(templateName))
    templateNameA = (LPCSTR)templateName;
  else
  {
    name = GetSystemString(templateName);
    templateNameA = name;
  }
  return DialogBoxParamA(g_hInstance, templateNameA, parentWindow, DialogProcedure, (LPARAM)this);
}
コード例 #20
0
ファイル: Window2.cpp プロジェクト: Ando02/wubiuefi
bool CWindow2::CreateEx(DWORD exStyle, LPCWSTR className, 
      LPCWSTR windowName, DWORD style,
      int x, int y, int width, int height,
      HWND parentWindow, HMENU idOrHMenu, 
      HINSTANCE instance)
{
  bool needRegister;
  if(g_IsNT)
  {
    WNDCLASSW windowClass;
    needRegister = ::GetClassInfoW(instance, className, &windowClass) == 0;
  }
  else
  {
    WNDCLASSA windowClassA;
    AString classNameA;
    LPCSTR classNameP;
    if (IS_INTRESOURCE(className))
      classNameP = (LPCSTR)className;
    else
    {
      classNameA = GetSystemString(className);
      classNameP = classNameA;
    }
    needRegister = ::GetClassInfoA(instance, classNameP, &windowClassA) == 0;
  }
  if (needRegister)
  {
    WNDCLASSW windowClass;
    // windowClass.style          = CS_HREDRAW | CS_VREDRAW;
    windowClass.style          = 0;
    windowClass.lpfnWndProc    = WindowProcedure;
    windowClass.cbClsExtra     = NULL;
    windowClass.cbWndExtra     = NULL;
    windowClass.hInstance      = instance;
    windowClass.hIcon          = NULL;
    windowClass.hCursor        = LoadCursor(NULL, IDC_ARROW);
    windowClass.hbrBackground  = (HBRUSH)(COLOR_WINDOW + 1);
    windowClass.lpszMenuName   = NULL;
    windowClass.lpszClassName  = className;
    if (MyRegisterClass(&windowClass) == 0)
      return false;
  }
  return CWindow::CreateEx(exStyle, className, windowName,
      style, x, y, width, height, parentWindow, 
      idOrHMenu, instance, this);

}
コード例 #21
0
ファイル: RegistryAssociations.cpp プロジェクト: BIAINC/7Zip
void WriteInternalAssociations(const CObjectVector<CExtInfo> &items)
{
  NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
  CKey mainKey;
  mainKey.Create(HKEY_CURRENT_USER, kCUKeyPath);
  mainKey.RecurseDeleteKey(kAssociations);
  CKey associationsKey;
  associationsKey.Create(mainKey, kAssociations);
  for(int i = 0; i < items.Size(); i++)
  {
    const CExtInfo &extInfo = items[i];
    CKey key;
    key.Create(associationsKey, GetSystemString(extInfo.Ext));
    key.SetValue(kExtPlugins, JoinStrings(extInfo.Plugins));
    // key.SetValue(kExtEnabled, extInfo.Enabled);
  }
}
コード例 #22
0
bool CMenu::InsertItem(UINT itemIndex, bool byPosition, const CMenuItem &item)
{
  #ifndef _UNICODE
  if (!g_IsNT)
  {
    MENUITEMINFOA si;
    ConvertItemToSysForm(item, si);
    AString s;
    if (item.IsString())
    {
      s = GetSystemString(item.StringValue);
      si.dwTypeData = (LPTSTR)(LPCTSTR)s;
    }
    return InsertItem(itemIndex, byPosition, &si);
  }
  else
  #endif
  {
    MENUITEMINFOW si;
    ConvertItemToSysForm(item, si);
    if (item.IsString())
      si.dwTypeData = (LPWSTR)(LPCWSTR)item.StringValue;
    #ifdef UNDER_CE
    UINT flags = (item.fType & MFT_SEPARATOR) ? MF_SEPARATOR : MF_STRING;
    UINT id = item.wID;
    if ((item.fMask & MIIM_SUBMENU) != 0)
    {
      flags |= MF_POPUP;
      id = (UINT)item.hSubMenu;
    }
    if (!Insert(itemIndex, flags | (byPosition ? MF_BYPOSITION : MF_BYCOMMAND), id, item.StringValue))
      return false;
    return SetItemInfo(itemIndex, byPosition, &si);
    #else
    return InsertItem(itemIndex, byPosition, &si);
    #endif
  }
}
コード例 #23
0
ファイル: Dialog.cpp プロジェクト: Alexander-r/physfs
bool CModelessDialog::Create(LPCWSTR templateName, HWND parentWindow)
{
  HWND aHWND;
  if (g_IsNT)
    aHWND = CreateDialogParamW(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
  else
  {
    AString name;
    LPCSTR templateNameA;
    if (IS_INTRESOURCE(templateName))
      templateNameA = (LPCSTR)templateName;
    else
    {
      name = GetSystemString(templateName);
      templateNameA = name;
    }
    aHWND = CreateDialogParamA(g_hInstance, templateNameA, parentWindow, DialogProcedure, (LPARAM)this);
  }
  if (aHWND == 0)
    return false;
  Attach(aHWND);
  return true;
}
コード例 #24
0
ファイル: Registry.cpp プロジェクト: headupinclouds/lzma-sdk
LONG CKey::QueryValue(LPCWSTR name, UString &value)
{
  value.Empty();
  DWORD type = 0;
  UInt32 currentSize = 0;

  LONG res;
  if (g_IsNT)
  {
    res = RegQueryValueExW(_object, name, NULL, &type, NULL, (DWORD *)&currentSize);
    if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA)
      return res;
    res = QueryValue(name, value.GetBuffer(currentSize), currentSize);
    value.ReleaseBuffer();
  }
  else
  {
    AString vTemp;
    res = QueryValue(name == 0 ? 0 : (LPCSTR)GetSystemString(name), vTemp);
    value = GetUnicodeString(vTemp);
  }
  return res;
}
コード例 #25
0
ファイル: ComboBox.cpp プロジェクト: ArchangelSDY/Qt7z
LRESULT CComboBox::AddString(LPCWSTR s)
{
  if (g_IsNT)
    return SendMsgW(CB_ADDSTRING, 0, (LPARAM)s);
  return AddString(GetSystemString(s));
}
コード例 #26
0
ファイル: PropertyPage.cpp プロジェクト: punesemu/puNES
INT_PTR MyPropertySheet(const CObjectVector<CPageInfo> &pagesInfo, HWND hwndParent, const UString &title)
{
#ifndef _UNICODE
    AStringVector titles;
#endif
#ifndef _UNICODE
    CRecordVector<PROPSHEETPAGEA> pagesA;
#endif
    CRecordVector<PROPSHEETPAGEW> pagesW;

    int i;
#ifndef _UNICODE
    for (i = 0; i < pagesInfo.Size(); i++)
        titles.Add(GetSystemString(pagesInfo[i].Title));
#endif

    for (i = 0; i < pagesInfo.Size(); i++)
    {
        const CPageInfo &pageInfo = pagesInfo[i];
#ifndef _UNICODE
        {
            PROPSHEETPAGE page;
            page.dwSize = sizeof(page);
            page.dwFlags = PSP_HASHELP;
            page.hInstance = g_hInstance;
            page.pszTemplate = MAKEINTRESOURCE(pageInfo.ID);
            page.pszIcon = NULL;
            page.pfnDlgProc = NWindows::NControl::MyProperyPageProcedure;

            if (titles[i].IsEmpty())
                page.pszTitle = NULL;
            else
            {
                page.dwFlags |= PSP_USETITLE;
                page.pszTitle = titles[i];
            }
            page.lParam = (LPARAM)pageInfo.Page;
            page.pfnCallback = NULL;
            pagesA.Add(page);
        }
#endif
        {
            PROPSHEETPAGEW page;
            page.dwSize = sizeof(page);
            page.dwFlags = PSP_HASHELP;
            page.hInstance = g_hInstance;
            page.pszTemplate = MAKEINTRESOURCEW(pageInfo.ID);
            page.pszIcon = NULL;
            page.pfnDlgProc = NWindows::NControl::MyProperyPageProcedure;

            if (pageInfo.Title.IsEmpty())
                page.pszTitle = NULL;
            else
            {
                page.dwFlags |= PSP_USETITLE;
                page.pszTitle = pageInfo.Title;
            }
            page.lParam = (LPARAM)pageInfo.Page;
            page.pfnCallback = NULL;
            pagesW.Add(page);
        }
    }

#ifndef _UNICODE
    if (!g_IsNT)
    {
        PROPSHEETHEADER sheet;
        sheet.dwSize = sizeof(sheet);
        sheet.dwFlags = PSH_PROPSHEETPAGE;
        sheet.hwndParent = hwndParent;
        sheet.hInstance = g_hInstance;
        AString titleA = GetSystemString(title);
        sheet.pszCaption = titleA;
        sheet.nPages = pagesInfo.Size();
        sheet.nStartPage = 0;
        sheet.ppsp = &pagesA.Front();
        sheet.pfnCallback = NULL;
        return ::PropertySheetA(&sheet);
    }
    else
#endif
    {
        PROPSHEETHEADERW sheet;
        sheet.dwSize = sizeof(sheet);
        sheet.dwFlags = PSH_PROPSHEETPAGE;
        sheet.hwndParent = hwndParent;
        sheet.hInstance = g_hInstance;
        sheet.pszCaption = title;
        sheet.nPages = pagesInfo.Size();
        sheet.nStartPage = 0;
        sheet.ppsp = &pagesW.Front();
        sheet.pfnCallback = NULL;
        return ::PropertySheetW(&sheet);
    }
}
コード例 #27
0
ファイル: CommonDialog.cpp プロジェクト: bks/qz7
bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, LPCWSTR s, UString &resPath)
{
  const int kBufferSize = MAX_PATH * 2;
  #ifndef _UNICODE
  if (!g_IsNT)
  {
    CHAR buffer[kBufferSize];
    MyStringCopy(buffer, (const char *)GetSystemString(fullFileName));
    OPENFILENAME info;
    info.lStructSize = sizeof(info);
    info.hwndOwner = hwnd;
    info.hInstance = 0;
    const int kFilterBufferSize = MAX_PATH;
    CHAR filterBuffer[kFilterBufferSize];
    CDoubleZeroStringListA doubleZeroStringList;
    doubleZeroStringList.Add(GetSystemString(s));
    doubleZeroStringList.Add("*.*");
    doubleZeroStringList.SetForBuffer(filterBuffer);
    info.lpstrFilter = filterBuffer;
    
    info.lpstrCustomFilter = NULL;
    info.nMaxCustFilter = 0;
    info.nFilterIndex = 0;
    
    info.lpstrFile = buffer;
    info.nMaxFile = kBufferSize;
    
    info.lpstrFileTitle = NULL;
    info.nMaxFileTitle = 0;
    
    info.lpstrInitialDir= NULL;

    info.lpstrTitle = 0;
    AString titleA;
    if (title != 0)
    {
      titleA = GetSystemString(title);
      info.lpstrTitle = titleA;
    }
    
    info.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
    info.nFileOffset = 0;
    info.nFileExtension = 0;
    info.lpstrDefExt = NULL;
    
    info.lCustData = 0;
    info.lpfnHook = NULL;
    info.lpTemplateName = NULL;
    
    bool res = BOOLToBool(::GetOpenFileNameA(&info));
    resPath = GetUnicodeString(buffer);
    return res;
  }
  else
  #endif
  {
    WCHAR buffer[kBufferSize];
    MyStringCopy(buffer, fullFileName);
    OPENFILENAMEW info;
    info.lStructSize = sizeof(info);
    info.hwndOwner = hwnd;
    info.hInstance = 0;
    const int kFilterBufferSize = MAX_PATH;
    WCHAR filterBuffer[kFilterBufferSize];
    CDoubleZeroStringListW doubleZeroStringList;
    doubleZeroStringList.Add(s);
    doubleZeroStringList.Add(L"*.*");
    doubleZeroStringList.SetForBuffer(filterBuffer);
    info.lpstrFilter = filterBuffer;
        
    info.lpstrCustomFilter = NULL;
    info.nMaxCustFilter = 0;
    info.nFilterIndex = 0;
    
    info.lpstrFile = buffer;
    info.nMaxFile = kBufferSize;
    
    info.lpstrFileTitle = NULL;
    info.nMaxFileTitle = 0;
    
    info.lpstrInitialDir= NULL;
       
    info.lpstrTitle = title;
    
    info.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
    info.nFileOffset = 0;
    info.nFileExtension = 0;
    info.lpstrDefExt = NULL;
    
    info.lCustData = 0;
    info.lpfnHook = NULL;
    info.lpTemplateName = NULL;
    
    bool res = BOOLToBool(::GetOpenFileNameW(&info));
    resPath = buffer;
    return res;
  }
}
コード例 #28
0
ファイル: CommonDialog.cpp プロジェクト: Alexander-r/physfs
bool MyGetOpenFileName(HWND hwnd, LPCWSTR title,
    LPCWSTR initialDir,
    LPCWSTR filePath,
    LPCWSTR filterDescription,
    LPCWSTR filter,
    UString &resPath
    #ifdef UNDER_CE
    , bool openFolder
    #endif
    )
{
  const unsigned kBufSize = MAX_PATH * 2;
  const unsigned kFilterBufSize = MAX_PATH;
  if (!filter)
    filter = L"*.*";
  #ifndef _UNICODE
  if (!g_IsNT)
  {
    CHAR buf[kBufSize];
    MyStringCopy(buf, (const char *)GetSystemString(filePath));
    // OPENFILENAME_NT4A
    OPENFILENAMEA p;
    memset(&p, 0, sizeof(p));
    p.lStructSize = my_compatib_OPENFILENAMEA_size;
    p.hwndOwner = hwnd;
    CHAR filterBuf[kFilterBufSize];
    {
      CDoubleZeroStringListA dz(filterBuf, kFilterBufSize);
      dz.Add(GetSystemString(filterDescription ? filterDescription : filter));
      dz.Add(GetSystemString(filter));
      dz.Finish();
      p.lpstrFilter = filterBuf;
      p.nFilterIndex = 1;
    }
    
    p.lpstrFile = buf;
    p.nMaxFile = kBufSize;
    CONV_U_To_A(p.lpstrInitialDir, initialDir, initialDirA);
    CONV_U_To_A(p.lpstrTitle, title, titleA);
    p.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;

    bool res = BOOLToBool(::GetOpenFileNameA(&p));
    resPath = GetUnicodeString(buf);
    return res;
  }
  else
  #endif
  {
    WCHAR buf[kBufSize];
    MyStringCopy(buf, filePath);
    // OPENFILENAME_NT4W
    OPENFILENAMEW p;
    memset(&p, 0, sizeof(p));
    p.lStructSize = my_compatib_OPENFILENAMEW_size;
    p.hwndOwner = hwnd;
    
    WCHAR filterBuf[kFilterBufSize];
    {
      CDoubleZeroStringListW dz(filterBuf, kFilterBufSize);
      dz.Add(filterDescription ? filterDescription : filter);
      dz.Add(filter);
      dz.Finish();
      p.lpstrFilter = filterBuf;
      p.nFilterIndex = 1;
    }
        
    p.lpstrFile = buf;
    p.nMaxFile = kBufSize;
    p.lpstrInitialDir = initialDir;
    p.lpstrTitle = title;
    p.Flags = OFN_EXPLORER | OFN_HIDEREADONLY
        #ifdef UNDER_CE
        | (openFolder ? (MY__OFN_PROJECT | MY__OFN_SHOW_ALL) : 0)
        #endif
        ;

    bool res = BOOLToBool(::GetOpenFileNameW(&p));
    resPath = buf;
    return res;
  }
}
コード例 #29
0
ファイル: File.cpp プロジェクト: donbex/spkutils
bool LZMAEncodeFile ( const char *fromFile, const char *toFile, CProgressInfo7Zip *progress )
{
	bool eos = false;

	CMyComPtr<ISequentialInStream> inStream;
	CInFileStream *inStreamSpec = new CInFileStream;
	inStream = inStreamSpec;

	if ( !inStreamSpec->Open ( GetSystemString(fromFile) ) )
		return false;

	CMyComPtr<ISequentialOutStream> outStream;
	COutFileStream *outStreamSpec = new COutFileStream;
	outStream = outStreamSpec;
	if ( !outStreamSpec->Create ( GetSystemString(toFile), true ) )
		return false;

    NCompress::NLZMA::CEncoder *encoderSpec = new NCompress::NLZMA::CEncoder;
    CMyComPtr<ICompressCoder> encoder = encoderSpec;

	UInt32 dictionary = 1 << 21;
    UInt32 posStateBits = 2;
    UInt32 litContextBits = 3; // for normal files
    // UInt32 litContextBits = 0; // for 32-bit data
    UInt32 litPosBits = 0;
    // UInt32 litPosBits = 2; // for 32-bit data
    UInt32 algorithm = 2;
    UInt32 numFastBytes = 128;
    UInt32 matchFinderCycles = 16 + numFastBytes / 2;
    bool matchFinderCyclesDefined = false;

    //bool eos = parser[NKey::kEOS].ThereIs || stdInMode;
 
    PROPID propIDs[] = 
    {
      NCoderPropID::kDictionarySize,
      NCoderPropID::kPosStateBits,
      NCoderPropID::kLitContextBits,
      NCoderPropID::kLitPosBits,
      NCoderPropID::kAlgorithm,
      NCoderPropID::kNumFastBytes,
      NCoderPropID::kMatchFinder,
      NCoderPropID::kEndMarker,
      NCoderPropID::kMatchFinderCycles
    };
    const int kNumPropsMax = sizeof(propIDs) / sizeof(propIDs[0]);

	UString mf = L"BT4";

    PROPVARIANT properties[kNumPropsMax];
    for (int p = 0; p < 6; p++)
      properties[p].vt = VT_UI4;

    properties[0].ulVal = UInt32(dictionary);
    properties[1].ulVal = UInt32(posStateBits);
    properties[2].ulVal = UInt32(litContextBits);
    properties[3].ulVal = UInt32(litPosBits);
    properties[4].ulVal = UInt32(algorithm);
    properties[5].ulVal = UInt32(numFastBytes);

    properties[8].vt = VT_UI4;
    properties[8].ulVal = UInt32(matchFinderCycles);
    
    properties[6].vt = VT_BSTR;
    properties[6].bstrVal = (BSTR)(const wchar_t *)mf;

    properties[7].vt = VT_BOOL;
    properties[7].boolVal = eos ? VARIANT_TRUE : VARIANT_FALSE;

    int numProps = kNumPropsMax;
    if (!matchFinderCyclesDefined)
      numProps--;

    if ( encoderSpec->SetCoderProperties(propIDs, properties, numProps) != S_OK )
		return false;
    encoderSpec->WriteCoderProperties(outStream);

	UInt64 fileSize = 0;
    if ( eos )
      fileSize = (UInt64)(Int64)-1;
    else
      inStreamSpec->File.GetLength(fileSize);

    for (int i = 0; i < 8; i++)
    {
      Byte b = Byte(fileSize >> (8 * i));
      if (outStream->Write(&b, 1, 0) != S_OK)
		  return false;
    }

	if ( progress )
	{
		progress->Init();
		progress->SetMax ( fileSize );
		progress->ApprovedStart = 1 << 21;
		progress->SetIn ( true );
	}

    HRESULT result = encoder->Code(inStream, outStream, 0, 0, progress );
    if (result == E_OUTOFMEMORY)
		return false;

    else if (result != S_OK)
		return false;

	return true;
}
コード例 #30
0
ファイル: FileSystem.cpp プロジェクト: BIAINC/7Zip
bool MyGetDiskFreeSpace(LPCWSTR rootPathName,
    UInt64 &clusterSize, UInt64 &totalSize, UInt64 &freeSize)
{
  return MyGetDiskFreeSpace(GetSystemString(rootPathName), clusterSize, totalSize, freeSize);
}