Subversion Repositories autosfx

Rev

Blame | Last modification | View Log | RSS feed

  1. #include "stdafx.h"
  2. #pragma hdrstop
  3. #if defined(UNICODE) && defined(ALLOW_WIN98)
  4. /* ***** BEGIN LICENSE BLOCK *****
  5.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  6.  *
  7.  * The contents of this file are subject to the Mozilla Public License Version
  8.  * 1.1 (the "License"); you may not use this file except in compliance with
  9.  * the License. You may obtain a copy of the License at
  10.  * http://www.mozilla.org/MPL/
  11.  *
  12.  * Software distributed under the License is distributed on an "AS IS" basis,
  13.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14.  * for the specific language governing rights and limitations under the
  15.  * License.
  16.  *
  17.  * The Original Code is for Open Layer for Unicode (opencow).
  18.  *
  19.  * The Initial Developer of the Original Code is Brodie Thiesfield.
  20.  * Portions created by the Initial Developer are Copyright (C) 2004
  21.  * the Initial Developer. All Rights Reserved.
  22.  *
  23.  * Contributor(s):
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  27.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38. /************************************************************************
  39.  Copyright (C) 2009, 2010  by Russell J. Peters, Roger Aelbrecht
  40.  
  41.    This file is part of TZipMaster Version 1.9.
  42.  
  43.     TZipMaster is free software: you can redistribute it and/or modify
  44.     it under the terms of the GNU Lesser General Public License as published by
  45.     the Free Software Foundation, either version 3 of the License, or
  46.     (at your option) any later version.
  47.  
  48.     TZipMaster is distributed in the hope that it will be useful,
  49.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  50.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  51.     GNU Lesser General Public License for more details.
  52.  
  53.     You should have received a copy of the GNU Lesser General Public License
  54.     along with TZipMaster.  If not, see <http://www.gnu.org/licenses/>.
  55.  
  56.     contact: problems@delphizip.org (include ZipMaster in the subject).
  57.     updates: http://www.delphizip.org
  58.     DelphiZip maillist subscribe at http://www.freelists.org/list/delphizip
  59. ************************************************************************/
  60.  
  61. // define these symbols so that we don't get dllimport linkage
  62. // from the system headers
  63. //#define _SHELL32_
  64.  
  65. //#include <windows.h>
  66. #include "MbcsBuffer.h"
  67. #include <shellapi.h>
  68. #include <shlobj.h>
  69. //#include "WinUser.h"
  70.  
  71.  
  72. // ----------------------------------------------------------------------------
  73. // API
  74.  
  75. // DragQueryFileW
  76. // ExtractIconExW
  77. // ExtractIconW
  78. // FindExecutableW
  79. #if 0
  80. EXTERN_C LPITEMIDLIST STDAPICALLTYPE
  81. SHBrowseForFolderW(
  82.     LPBROWSEINFOW lpbi
  83.     )
  84. {
  85.     char mbcsDisplayName[MAX_PATH];
  86.  
  87.     BROWSEINFOA biA;
  88.     ::ZeroMemory(&biA, sizeof(biA));
  89.  
  90.     biA.hwndOwner       = lpbi->hwndOwner;
  91.     biA.pidlRoot        = lpbi->pidlRoot;
  92.     biA.ulFlags         = lpbi->ulFlags;
  93.     biA.lpfn            = lpbi->lpfn;
  94.     biA.lParam          = lpbi->lParam;
  95.     biA.iImage          = lpbi->iImage;
  96.     biA.pszDisplayName  = mbcsDisplayName;
  97.  
  98.     CMbcsBuffer mbcsTitle;
  99.     if (!mbcsTitle.FromUnicode(lpbi->lpszTitle))
  100.         return NULL;
  101.     biA.lpszTitle = mbcsTitle;
  102.  
  103.     LPITEMIDLIST result = ::SHBrowseForFolderA(&biA);
  104.     if (!result)
  105.         return NULL;
  106.  
  107.     ::MultiByteToWideChar(CP_ACP, 0, mbcsDisplayName, -1, lpbi->pszDisplayName, MAX_PATH);
  108.     return result;
  109. }
  110. #endif
  111. // SHChangeNotify
  112. #if 0
  113. extern "C" void WINAPI zSHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
  114. {
  115.     if (!(uFlags & SHCNF_PATH))
  116.     {
  117.        ::SHChangeNotify(wEventId, uFlags, dwItem1, dwItem2);
  118.        return;
  119.     }  
  120.     CMbcsBuffer mbcsItem1;
  121.     if (!mbcsItem1.FromUnicode((LPCTSTR)dwItem1))
  122.         return ;        
  123.     char *item2 = 0;
  124.     if (dwItem2)
  125.     {
  126.     CMbcsBuffer mbcsItem2;
  127.         if (!mbcsItem2.FromUnicode((LPCTSTR)dwItem2))
  128.             return ;          
  129.         item2 = mbcsItem2;
  130.     }
  131.     ::SHChangeNotify(wEventId, uFlags, mbcsItem1, item2);
  132. }
  133. #endif
  134. // SHFileOperationW
  135. int zzlen(LPCTSTR str)
  136. {
  137.     if (!str || !*str)
  138.         return 0;
  139.  
  140.     int r = 0;
  141.     do
  142.     {
  143.         for (str; *str; str++)
  144.             r++;
  145.         r++;
  146.     }
  147.     while (*++str);
  148.     return r;
  149. }
  150.  
  151. extern "C" int WINAPI zSHFileOperationW(LPSHFILEOPSTRUCT lpFileOp)
  152. {
  153.     CMbcsBuffer mbcsFrom;
  154.     CMbcsBuffer mbcsTo;
  155.     CMbcsBuffer mbcsTitle;
  156.     if (lpFileOp->pFrom)
  157.     {
  158.         int FromLen = zzlen(lpFileOp->pFrom);
  159.         if (!mbcsFrom.FromUnicode(lpFileOp->pFrom, FromLen))
  160.             return 0x81;
  161.         lpFileOp->pFrom = (TCHAR*)mbcsFrom.get();
  162.     }
  163.     if (lpFileOp->pTo)
  164.     {
  165.         int ToLen = zzlen(lpFileOp->pTo);
  166.         if (!mbcsTo.FromUnicode(lpFileOp->pTo, ToLen))
  167.             return 0x81;
  168.         lpFileOp->pTo = (TCHAR*)mbcsTo.get();
  169.     }
  170.     if (lpFileOp->lpszProgressTitle)
  171.     {
  172.         int TitleLen = zzlen(lpFileOp->lpszProgressTitle);
  173.         if (!mbcsTitle.FromUnicode(lpFileOp->lpszProgressTitle, TitleLen))
  174.             return 0x81;
  175.         lpFileOp->lpszProgressTitle = (TCHAR*)mbcsTitle.get();
  176.     }
  177.     return ::SHFileOperationA((_SHFILEOPSTRUCTA *)lpFileOp);
  178. }
  179. // SHGetFileInfoW
  180. // SHGetNewLinkInfoW
  181. #if 0
  182. EXTERN_C BOOL STDAPICALLTYPE
  183. SHGetPathFromIDListW(
  184.     LPCITEMIDLIST pidl,
  185.     LPWSTR pszPath
  186.     )
  187. {
  188.     char mbcsPath[MAX_PATH];
  189.     BOOL success = ::SHGetPathFromIDListA(pidl, mbcsPath);
  190.     if (!success)
  191.         return FALSE;
  192.  
  193.     int nResult = ::MultiByteToWideChar(CP_ACP, 0, mbcsPath, -1, pszPath, MAX_PATH);
  194.     if (nResult < 1)
  195.         return FALSE;
  196.  
  197.     return TRUE;
  198. }
  199.  
  200. EXTERN_C INT STDAPICALLTYPE
  201. ShellAboutW(
  202.     HWND hWnd,
  203.     LPCWSTR szApp,
  204.     LPCWSTR szOtherStuff,
  205.     HICON hIcon
  206.     )
  207. {
  208.     CMbcsBuffer mbcsApp;
  209.     if (!mbcsApp.FromUnicode(szApp))
  210.         return 0;
  211.  
  212.     CMbcsBuffer mbcsOtherStuff;
  213.     if (!mbcsOtherStuff.FromUnicode(szOtherStuff))
  214.         return 0;
  215.  
  216.     return ::ShellAboutA(hWnd, mbcsApp, mbcsOtherStuff, hIcon);
  217. }
  218.  
  219. // ShellExecuteExW
  220.  
  221. EXTERN_C HINSTANCE STDAPICALLTYPE
  222. ShellExecuteW(
  223.     HWND hwnd,
  224.     LPCWSTR lpOperation,
  225.     LPCWSTR lpFile,
  226.     LPCWSTR lpParameters,
  227.     LPCWSTR lpDirectory,
  228.     INT nShowCmd
  229.     )
  230. {
  231.     CMbcsBuffer mbcsOperation;
  232.     if (!mbcsOperation.FromUnicode(lpOperation))
  233.         return 0;
  234.  
  235.     CMbcsBuffer mbcsFile;
  236.     if (!mbcsFile.FromUnicode(lpFile))
  237.         return 0;
  238.  
  239.     CMbcsBuffer mbcsParameters;
  240.     if (!mbcsParameters.FromUnicode(lpParameters))
  241.         return 0;
  242.  
  243.     CMbcsBuffer mbcsDirectory;
  244.     if (!mbcsDirectory.FromUnicode(lpDirectory))
  245.         return 0;
  246.  
  247.     return ::ShellExecuteA(hwnd, mbcsOperation, mbcsFile, mbcsParameters, mbcsDirectory, nShowCmd);
  248. }
  249. #endif
  250. // Shell_NotifyIconW
  251. #endif
  252.