diff options
author | George Hazan <ghazan@miranda.im> | 2017-10-08 22:13:50 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-10-08 22:13:50 +0300 |
commit | 352b28a3f370411bb6236aced12943ec0e954c7a (patch) | |
tree | 02adb830ce6bde7509d22b2f879fa6dbfa24865e | |
parent | 819f67e42f7e93139e378d45518fa5a697cc9705 (diff) |
miranda32.exe became static to be independent from VS runtime
-rw-r--r-- | src/miranda32/miranda32.vcxproj | 6 | ||||
-rw-r--r-- | src/miranda32/src/miranda.cpp | 29 |
2 files changed, 29 insertions, 6 deletions
diff --git a/src/miranda32/miranda32.vcxproj b/src/miranda32/miranda32.vcxproj index 902624bf99..42e4435e2d 100644 --- a/src/miranda32/miranda32.vcxproj +++ b/src/miranda32/miranda32.vcxproj @@ -42,5 +42,11 @@ <Link>
<AdditionalManifestDependencies>type=%27win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27*%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;type=%27win32%27 name=%27Microsoft.Windows.Gdiplus%27 version=%271.0.0.0%27 processorArchitecture=%27*%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies)</AdditionalManifestDependencies>
</Link>
+ <ClCompile>
+ <RuntimeLibrary Condition="'$(Configuration)'=='Debug'">MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <ClCompile>
+ <RuntimeLibrary Condition="'$(Configuration)'=='Release'">MultiThreaded</RuntimeLibrary>
+ </ClCompile>
</ItemDefinitionGroup>
</Project>
\ No newline at end of file diff --git a/src/miranda32/src/miranda.cpp b/src/miranda32/src/miranda.cpp index a42b367110..aa89b9bf29 100644 --- a/src/miranda32/src/miranda.cpp +++ b/src/miranda32/src/miranda.cpp @@ -26,13 +26,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. typedef int (WINAPI *pfnMain)(LPTSTR);
+#ifdef _WIN64
+const wchar_t wszRuntimeUrl[] = L"https://download.visualstudio.microsoft.com/download/pr/11100230/15ccb3f02745c7b206ad10373cbca89b/VC_redist.x64.exe";
+#else
+const wchar_t wszRuntimeUrl[] = L"https://download.visualstudio.microsoft.com/download/pr/11100229/78c1e864d806e36f6035d80a0e80399e/VC_redist.x86.exe";
+#endif
+
+const wchar_t wszQuestion[] = L"Miranda NG needs the Visual Studio runtime library, but it cannot be loaded. Do you want to load it from Inernet?";
+
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR cmdLine, int)
{
wchar_t tszPath[MAX_PATH];
GetModuleFileName(hInstance, tszPath, _countof(tszPath));
wchar_t *p = wcsrchr(tszPath, '\\');
- if (p == NULL)
+ if (p == nullptr)
return 4;
// if current dir isn't set
@@ -42,7 +50,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR cmdLine, int) wcsncat_s(tszPath, L"libs", _TRUNCATE);
DWORD cbPath = (DWORD)wcslen(tszPath);
- DWORD cbSize = GetEnvironmentVariable(L"PATH", NULL, 0);
+ DWORD cbSize = GetEnvironmentVariable(L"PATH", nullptr, 0);
wchar_t *ptszVal = new wchar_t[cbSize + MAX_PATH + 2];
wcscpy(ptszVal, tszPath);
wcscat(ptszVal, L";");
@@ -51,14 +59,23 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR cmdLine, int) int retVal;
HINSTANCE hMirApp = LoadLibrary(L"mir_app.mir");
- if (hMirApp == NULL) {
- MessageBox(NULL, L"mir_app.mir cannot be loaded", L"Fatal error", MB_ICONERROR | MB_OK);
+ if (hMirApp == nullptr) {
retVal = 1;
+
+ // zlib depends on runtime only. if it cannot be loaded too, we need to load a runtime
+ HINSTANCE hZlib = LoadLibrary(L"Libs\\zlib.mir");
+ if (hZlib == nullptr) {
+ if (IDYES == MessageBox(nullptr, wszQuestion, L"Missing runtime library", MB_ICONERROR | MB_YESNOCANCEL)) {
+ ShellExecute(nullptr, L"open", wszRuntimeUrl, NULL, NULL, SW_NORMAL);
+ retVal = 3;
+ }
+ }
+ else MessageBox(nullptr, L"mir_app.mir cannot be loaded", L"Fatal error", MB_ICONERROR | MB_OK);
}
else {
pfnMain fnMain = (pfnMain)GetProcAddress(hMirApp, "mir_main");
- if (fnMain == NULL) {
- MessageBox(NULL, L"invalid mir_app.mir present, program exiting", L"Fatal error", MB_ICONERROR | MB_OK);
+ if (fnMain == nullptr) {
+ MessageBox(nullptr, L"invalid mir_app.mir present, program exiting", L"Fatal error", MB_ICONERROR | MB_OK);
retVal = 2;
}
else
|