main.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Internet Explorer wrapper
  3. *
  4. * Copyright 2006 Mike McCormack
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  19. */
  20. #include <windows.h>
  21. #include <advpub.h>
  22. #include <ole2.h>
  23. #include <rpcproxy.h>
  24. #include "wine/debug.h"
  25. extern DWORD WINAPI IEWinMain(const WCHAR*, int);
  26. static BOOL check_native_ie(void)
  27. {
  28. DWORD handle, size;
  29. LPWSTR file_desc;
  30. UINT bytes;
  31. void* buf;
  32. BOOL ret = TRUE;
  33. LPWORD translation;
  34. static const WCHAR browseui_dllW[] = {'b','r','o','w','s','e','u','i','.','d','l','l',0};
  35. static const WCHAR wineW[] = {'W','i','n','e',0};
  36. static const WCHAR translationW[] =
  37. {'\\','V','a','r','F','i','l','e','I','n','f','o',
  38. '\\','T','r','a','n','s','l','a','t','i','o','n',0};
  39. static const WCHAR file_desc_fmtW[] =
  40. {'\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
  41. '\\','%','0','4','x','%','0','4','x',
  42. '\\','F','i','l','e','D','e','s','c','r','i','p','t','i','o','n',0};
  43. WCHAR file_desc_strW[48];
  44. size = GetFileVersionInfoSizeW(browseui_dllW, &handle);
  45. if(!size)
  46. return TRUE;
  47. buf = HeapAlloc(GetProcessHeap(), 0, size);
  48. GetFileVersionInfoW(browseui_dllW, 0, size,buf);
  49. if (VerQueryValueW(buf, translationW, (void **)&translation, &bytes))
  50. {
  51. wsprintfW(file_desc_strW, file_desc_fmtW, translation[0], translation[1]);
  52. ret = !VerQueryValueW(buf, file_desc_strW, (void**)&file_desc, &bytes) || !wcsstr(file_desc, wineW);
  53. }
  54. HeapFree(GetProcessHeap(), 0, buf);
  55. return ret;
  56. }
  57. static DWORD register_iexplore(BOOL doregister)
  58. {
  59. HRESULT hres;
  60. if (check_native_ie()) {
  61. WINE_MESSAGE("Native IE detected, not doing registration\n");
  62. return 0;
  63. }
  64. hres = RegInstallA(NULL, doregister ? "RegisterIE" : "UnregisterIE", NULL);
  65. return FAILED(hres);
  66. }
  67. int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE prev, WCHAR *cmdline, int show)
  68. {
  69. static const WCHAR regserverW[] = {'r','e','g','s','e','r','v','e','r',0};
  70. static const WCHAR unregserverW[] = {'u','n','r','e','g','s','e','r','v','e','r',0};
  71. if(*cmdline == '-' || *cmdline == '/') {
  72. if(!wcsicmp(cmdline+1, regserverW))
  73. return register_iexplore(TRUE);
  74. if(!wcsicmp(cmdline+1, unregserverW))
  75. return register_iexplore(FALSE);
  76. }
  77. return IEWinMain(cmdline, show);
  78. }