diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2015-08-15 10:56:06 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2015-08-15 10:56:06 +0000 |
commit | 761620b2f9291f8e45816c7c93cbbbbf97b06254 (patch) | |
tree | f35df4ebff355e8c725b9289a9c04ce190d72518 | |
parent | 1db4b29d772702e85571b12172f9e3f86bf095b0 (diff) |
minor fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@14958 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | src/miranda32/src/miranda.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/miranda32/src/miranda.cpp b/src/miranda32/src/miranda.cpp index e406740196..73540768e3 100644 --- a/src/miranda32/src/miranda.cpp +++ b/src/miranda32/src/miranda.cpp @@ -24,6 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
+typedef int (WINAPI *pfnMain)(LPTSTR);
+
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR cmdLine, int)
{
TCHAR tszPath[MAX_PATH];
@@ -40,9 +42,9 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR cmdLine, int) // all old dlls must be removed
CheckDlls();
- _tcsncat(tszPath, _T("libs"), _TRUNCATE);
+ _tcsncat_s(tszPath, _T("libs"), _TRUNCATE);
DWORD cbPath = (DWORD)_tcslen(tszPath);
-
+
DWORD cbSize = GetEnvironmentVariable(_T("PATH"), NULL, 0);
TCHAR *ptszVal = new TCHAR[cbSize + MAX_PATH + 2];
_tcscpy(ptszVal, tszPath);
@@ -50,20 +52,22 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR cmdLine, int) GetEnvironmentVariable(_T("PATH"), ptszVal + cbPath + 1, cbSize);
SetEnvironmentVariable(_T("PATH"), ptszVal);
- HINSTANCE hMirApp = LoadLibraryA("mir_app.mir");
+ int retVal;
+ HINSTANCE hMirApp = LoadLibrary(_T("mir_app.mir"));
if (hMirApp == NULL) {
MessageBox(NULL, _T("mir_app.mir cannot be loaded"), _T("Fatal error"), MB_ICONERROR | MB_OK);
- return 1;
+ retVal = 1;
}
-
- typedef int (WINAPI *pfnMain)(LPTSTR);
- pfnMain fnMain = (pfnMain)GetProcAddress(hMirApp, "mir_main");
- if (fnMain == NULL) {
- MessageBox(NULL, _T("invalid mir_app.mir present, program exiting"), _T("Fatal error"), MB_ICONERROR | MB_OK);
- return 2;
+ else {
+ pfnMain fnMain = (pfnMain)GetProcAddress(hMirApp, "mir_main");
+ if (fnMain == NULL) {
+ MessageBox(NULL, _T("invalid mir_app.mir present, program exiting"), _T("Fatal error"), MB_ICONERROR | MB_OK);
+ retVal = 2;
+ }
+ else
+ retVal = fnMain(cmdLine);
+ FreeLibrary(hMirApp);
}
-
- int retVal = fnMain(cmdLine);
- FreeLibrary(hMirApp);
+ delete[] ptszVal;
return retVal;
}
|