From 52c87eaf68d8ba2048bd822588ceb2e2faf8f20e Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Fri, 10 Jan 2014 12:43:53 +0200 Subject: Adds splash screen. --- src/native/windows/run/run.c | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'src/native/windows') diff --git a/src/native/windows/run/run.c b/src/native/windows/run/run.c index 581286c..2829f77 100644 --- a/src/native/windows/run/run.c +++ b/src/native/windows/run/run.c @@ -66,6 +66,9 @@ static DWORD Run_runJavaFromRegKey(HKEY key, BOOL *searchForJava); static DWORD Run_runJavaFromRuntimeLib(LPCTSTR runtimeLib, LPCTSTR javaHome, BOOL *searchForJava); static LPSTR Run_skipWhitespace(LPSTR str); +typedef void (CALLBACK *SplashInit)(); +typedef int (CALLBACK *SplashLoadFile)(const char* file); + static DWORD Run_addPath(LPCTSTR path) { @@ -1533,6 +1536,53 @@ Run_runJavaFromRuntimeLib javaVMInitArgs.nOptions = optionStringCount; javaVMInitArgs.options = options; javaVMInitArgs.version = JNI_VERSION_1_2; + + HMODULE hSplash = NULL; + LPTSTR lockFilePath = Run_getLockFilePath(); + + if(!(lockFilePath && Run_isFile(lockFilePath))) + {// Lets load and start splashscreen, if any + size_t javaHomeLength = _tcslen(javaHome); + LPTSTR path + = (LPTSTR) malloc(sizeof(TCHAR) + * (javaHomeLength + 20 + 1)); + if (path) + { + if (javaHomeLength >= 1) + { + TCHAR *ch = + (TCHAR *) (javaHome + (javaHomeLength - 1)); + + if ((_T('\\') == *ch) || (_T('/') == *ch)) + { + *ch = 0; + javaHomeLength--; + } + } + + _tcscpy(path, javaHome); + _tcscpy(path + javaHomeLength, + _T("\\bin\\splashscreen.dll")); + hSplash = LoadLibrary(path); + + if(hSplash > 0) + { + SplashInit splashInit = + (SplashInit)GetProcAddress( + hSplash, "SplashInit"); + SplashLoadFile splashLoadFile = + (SplashLoadFile)GetProcAddress( + hSplash, "SplashLoadFile"); + + if (splashInit && splashLoadFile) + { + splashInit(); + splashLoadFile("splash.gif"); + } + } + } + } + if (jniCreateJavaVM( &javaVM, (void **) &jniEnv, @@ -1553,6 +1603,9 @@ Run_runJavaFromRuntimeLib } if (options) free(options); + + if(hSplash) + FreeLibrary(hSplash); } else error = ERROR_OUTOFMEMORY; -- cgit v1.1