home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Quality Assurance
Bugreports
Archive
Redirected log path: some files created in standard path
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Owlsroost" data-source="post: 1149585" data-attributes="member: 83973"><p>This is what the C++ code looks like:</p><p></p><p>[code]</p><p>LONG LogWriteRegistryKeyString(HKEY hKey, LPCTSTR& lpSubKey, LPCTSTR& data)</p><p>{</p><p> LONG result = RegSetValueEx(hKey, lpSubKey, 0, REG_SZ, (LPBYTE)data, _tcslen(data) * sizeof(TCHAR));</p><p></p><p> return result;</p><p>}</p><p></p><p>LONG LogReadRegistryKeyString(HKEY hKey, LPCTSTR& lpSubKey, LPCTSTR& data)</p><p>{</p><p> DWORD dwSize = MAX_PATH * sizeof(TCHAR);</p><p> DWORD dwType = REG_SZ;</p><p> LONG result = RegQueryValueEx(hKey, lpSubKey, NULL, &dwType, (PBYTE)data, &dwSize);</p><p></p><p> if (result != ERROR_SUCCESS)</p><p> {</p><p> if (result == ERROR_FILE_NOT_FOUND)</p><p> {</p><p> //create default value</p><p> result = LogWriteRegistryKeyString(hKey, lpSubKey, data);</p><p> }</p><p> }</p><p></p><p> return result;</p><p>}</p><p></p><p>void LogPath(TCHAR* dest, TCHAR* name)</p><p>{</p><p> CAutoLock lock(&m_logFileLock);</p><p> HKEY hKey;</p><p> //Try to read logging folder path from registry</p><p> LONG result = RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Team MediaPortal\\Client Common"), 0, NULL,</p><p> REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL); </p><p> if (result == ERROR_SUCCESS)</p><p> {</p><p> //Get default log folder path</p><p> TCHAR folder[MAX_PATH];</p><p> SHGetSpecialFolderPath(NULL,folder,CSIDL_COMMON_APPDATA,FALSE);</p><p> TCHAR logFolder[MAX_PATH];</p><p> _stprintf(logFolder, _T("%s\\Team Mediaportal\\MediaPortal\\log"), folder);</p><p></p><p> //Read log folder path from registry (or write default path into registry if key doesn't exist)</p><p> LPCTSTR logFolderC = logFolder; </p><p> LPCTSTR logFolderPath = _T("LogFolderPath");</p><p> result = LogReadRegistryKeyString(hKey, logFolderPath, logFolderC);</p><p> </p><p> if (result == ERROR_SUCCESS)</p><p> {</p><p> //Get full log file path</p><p> _stprintf(dest, _T("%s\\TsReader.%s"), logFolderC, name);</p><p> }</p><p> }</p><p> </p><p> if (result != ERROR_SUCCESS)</p><p> {</p><p> //Fall back to default log folder path</p><p> TCHAR folder[MAX_PATH];</p><p> SHGetSpecialFolderPath(NULL,folder,CSIDL_COMMON_APPDATA,FALSE);</p><p> //Get full log file path</p><p> _stprintf(dest, _T("%s\\Team Mediaportal\\MediaPortal\\log\\TsReader.%s"), folder, name);</p><p> }</p><p>}</p><p>[/code]</p><p></p><p>Basically it calls 'RegCreateKeyEx' to find out if the key 'HKEY_CURRENT_USER\Software\Team MediaPortal\Client Common' exists and create it if it doesn't.</p><p></p><p>Then it calls 'RegQueryValueEx' to get the 'LogFolderPath' value - if that value doesn't exist it creates it using 'RegSetValueEx' (with the default path value).</p><p></p><p>So I guess doing something similar on the C# should work, except that since MP is going to be the 'master' here, it can just overwrite the 'LogFolderPath' value with whatever is in MediaPortalDirs.xml each time (on MP startup ?)</p><p></p><p>(Ignoring the problem of accessing the registry from .NET of course <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink ;)" loading="lazy" data-shortname=";)" />- <a href="http://stackoverflow.com/questions/1470770/accessing-the-windows-registry-using-net" target="_blank">http://stackoverflow.com/questions/1470770/accessing-the-windows-registry-using-net</a> )</p></blockquote><p></p>
[QUOTE="Owlsroost, post: 1149585, member: 83973"] This is what the C++ code looks like: [code] LONG LogWriteRegistryKeyString(HKEY hKey, LPCTSTR& lpSubKey, LPCTSTR& data) { LONG result = RegSetValueEx(hKey, lpSubKey, 0, REG_SZ, (LPBYTE)data, _tcslen(data) * sizeof(TCHAR)); return result; } LONG LogReadRegistryKeyString(HKEY hKey, LPCTSTR& lpSubKey, LPCTSTR& data) { DWORD dwSize = MAX_PATH * sizeof(TCHAR); DWORD dwType = REG_SZ; LONG result = RegQueryValueEx(hKey, lpSubKey, NULL, &dwType, (PBYTE)data, &dwSize); if (result != ERROR_SUCCESS) { if (result == ERROR_FILE_NOT_FOUND) { //create default value result = LogWriteRegistryKeyString(hKey, lpSubKey, data); } } return result; } void LogPath(TCHAR* dest, TCHAR* name) { CAutoLock lock(&m_logFileLock); HKEY hKey; //Try to read logging folder path from registry LONG result = RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Team MediaPortal\\Client Common"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL); if (result == ERROR_SUCCESS) { //Get default log folder path TCHAR folder[MAX_PATH]; SHGetSpecialFolderPath(NULL,folder,CSIDL_COMMON_APPDATA,FALSE); TCHAR logFolder[MAX_PATH]; _stprintf(logFolder, _T("%s\\Team Mediaportal\\MediaPortal\\log"), folder); //Read log folder path from registry (or write default path into registry if key doesn't exist) LPCTSTR logFolderC = logFolder; LPCTSTR logFolderPath = _T("LogFolderPath"); result = LogReadRegistryKeyString(hKey, logFolderPath, logFolderC); if (result == ERROR_SUCCESS) { //Get full log file path _stprintf(dest, _T("%s\\TsReader.%s"), logFolderC, name); } } if (result != ERROR_SUCCESS) { //Fall back to default log folder path TCHAR folder[MAX_PATH]; SHGetSpecialFolderPath(NULL,folder,CSIDL_COMMON_APPDATA,FALSE); //Get full log file path _stprintf(dest, _T("%s\\Team Mediaportal\\MediaPortal\\log\\TsReader.%s"), folder, name); } } [/code] Basically it calls 'RegCreateKeyEx' to find out if the key 'HKEY_CURRENT_USER\Software\Team MediaPortal\Client Common' exists and create it if it doesn't. Then it calls 'RegQueryValueEx' to get the 'LogFolderPath' value - if that value doesn't exist it creates it using 'RegSetValueEx' (with the default path value). So I guess doing something similar on the C# should work, except that since MP is going to be the 'master' here, it can just overwrite the 'LogFolderPath' value with whatever is in MediaPortalDirs.xml each time (on MP startup ?) (Ignoring the problem of accessing the registry from .NET of course ;)- [URL]http://stackoverflow.com/questions/1470770/accessing-the-windows-registry-using-net[/URL] ) [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Quality Assurance
Bugreports
Archive
Redirected log path: some files created in standard path
Contact us
RSS
Top
Bottom