diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index 87873b3e11..4543cf0e34 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -682,60 +682,6 @@ void SortCStringArray( CStringArray &arrayCStrings, const bool bSortAscending ) bSortAscending?CompareCStringsAsc:CompareCStringsDesc); } - - -LONG GetRegKey(HKEY key, const char *subkey, LPTSTR retdata) -{ - HKEY hkey; - LONG retval = RegOpenKeyEx(key, subkey, 0, KEY_QUERY_VALUE, &hkey); - - if (retval == ERROR_SUCCESS) { - long datasize = MAX_PATH; - TCHAR data[MAX_PATH]; - RegQueryValue(hkey, NULL, data, &datasize); - lstrcpy(retdata,data); - RegCloseKey(hkey); - } - - return retval; -} - -HINSTANCE GotoURL(const char *url) -{ - TCHAR key[MAX_PATH + MAX_PATH]; - - // First try ShellExecute() - HINSTANCE result = ShellExecute(NULL, _T("open"), url, NULL,NULL, SW_SHOWDEFAULT); - - // If it failed, get the .htm regkey and lookup the program - if ((UINT)result <= HINSTANCE_ERROR) { - - if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS) { - lstrcat(key, _T("\\shell\\open\\command")); - - if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS) { - TCHAR *pos; - pos = _tcsstr(key, _T("\"%1\"")); - if (pos == NULL) { // No quotes found - pos = strstr(key, _T("%1")); // Check for %1, without quotes - if (pos == NULL) // No parameter at all... - pos = key+lstrlen(key)-1; - else - *pos = '\0'; // Remove the parameter - } - else - *pos = '\0'; // Remove the parameter - - lstrcat(pos, _T(" ")); - lstrcat(pos, url); - result = (HINSTANCE) WinExec(key,SW_SHOWDEFAULT); - } - } - } - - return result; -} - float calc_mean(const float *start, const float *end) { return accumulate(start, end, 0.f) / distance(start, end); diff --git a/stepmania/src/RageUtil.h b/stepmania/src/RageUtil.h index b545744de0..b824c76009 100644 --- a/stepmania/src/RageUtil.h +++ b/stepmania/src/RageUtil.h @@ -179,10 +179,6 @@ bool CompareCStringsAsc(const CString &str1, const CString &str2); bool CompareCStringsDesc(const CString &str1, const CString &str2); void SortCStringArray( CStringArray &AddTo, const bool bSortAcsending = true ); - -LONG GetRegKey(HKEY key, const char *subkey, LPTSTR retdata); -HINSTANCE GotoURL(const char *url); - /* Find the mean and standard deviation of all numbers in [start,end). */ float calc_mean(const float *start, const float *end); float calc_stddev(const float *start, const float *end); diff --git a/stepmania/src/archutils/Win32/GotoURL.cpp b/stepmania/src/archutils/Win32/GotoURL.cpp new file mode 100644 index 0000000000..31c0a393f6 --- /dev/null +++ b/stepmania/src/archutils/Win32/GotoURL.cpp @@ -0,0 +1,54 @@ +#include "../../stdafx.h" +#include "GotoURL.h" + +static LONG GetRegKey(HKEY key, const char *subkey, LPTSTR retdata) +{ + HKEY hkey; + LONG retval = RegOpenKeyEx(key, subkey, 0, KEY_QUERY_VALUE, &hkey); + + if (retval == ERROR_SUCCESS) { + long datasize = MAX_PATH; + TCHAR data[MAX_PATH]; + RegQueryValue(hkey, NULL, data, &datasize); + lstrcpy(retdata,data); + RegCloseKey(hkey); + } + + return retval; +} + +HINSTANCE GotoURL(const char *url) +{ + TCHAR key[MAX_PATH + MAX_PATH]; + + // First try ShellExecute() + HINSTANCE result = ShellExecute(NULL, _T("open"), url, NULL,NULL, SW_SHOWDEFAULT); + + // If it failed, get the .htm regkey and lookup the program + if ((UINT)result <= HINSTANCE_ERROR) { + + if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS) { + lstrcat(key, _T("\\shell\\open\\command")); + + if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS) { + TCHAR *pos; + pos = _tcsstr(key, _T("\"%1\"")); + if (pos == NULL) { // No quotes found + pos = strstr(key, _T("%1")); // Check for %1, without quotes + if (pos == NULL) // No parameter at all... + pos = key+lstrlen(key)-1; + else + *pos = '\0'; // Remove the parameter + } + else + *pos = '\0'; // Remove the parameter + + lstrcat(pos, _T(" ")); + lstrcat(pos, url); + result = (HINSTANCE) WinExec(key,SW_SHOWDEFAULT); + } + } + } + + return result; +} diff --git a/stepmania/src/archutils/Win32/GotoURL.h b/stepmania/src/archutils/Win32/GotoURL.h new file mode 100644 index 0000000000..1a7af7d3a9 --- /dev/null +++ b/stepmania/src/archutils/Win32/GotoURL.h @@ -0,0 +1,6 @@ +#ifndef GOTO_URL_H +#define GOTO_URL_H + +HINSTANCE GotoURL(const char *url); + +#endif \ No newline at end of file