main.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. WCHAR file_desc_strW[48];
  35. size = GetFileVersionInfoSizeW(L"browseui.dll", &handle);
  36. if(!size)
  37. return TRUE;
  38. buf = HeapAlloc(GetProcessHeap(), 0, size);
  39. GetFileVersionInfoW(L"browseui.dll", 0, size,buf);
  40. if (VerQueryValueW(buf, L"\\VarFileInfo\\Translation", (void **)&translation, &bytes))
  41. {
  42. wsprintfW(file_desc_strW, L"\\StringFileInfo\\%04x%04x\\FileDescription", translation[0], translation[1]);
  43. ret = !VerQueryValueW(buf, file_desc_strW, (void**)&file_desc, &bytes) || !wcsstr(file_desc, L"Wine");
  44. }
  45. HeapFree(GetProcessHeap(), 0, buf);
  46. return ret;
  47. }
  48. static DWORD register_iexplore(BOOL doregister)
  49. {
  50. HRESULT hres;
  51. if (check_native_ie()) {
  52. WINE_MESSAGE("Native IE detected, not doing registration\n");
  53. return 0;
  54. }
  55. hres = RegInstallA(NULL, doregister ? "RegisterIE" : "UnregisterIE", NULL);
  56. return FAILED(hres);
  57. }
  58. int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE prev, WCHAR *cmdline, int show)
  59. {
  60. SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE);
  61. if(*cmdline == '-' || *cmdline == '/') {
  62. if(!wcsicmp(cmdline+1, L"regserver"))
  63. return register_iexplore(TRUE);
  64. if(!wcsicmp(cmdline+1, L"unregserver"))
  65. return register_iexplore(FALSE);
  66. }
  67. return IEWinMain(cmdline, show);
  68. }