I have existing code that does this when the application starts:
m_strAppLoc = __targv;
m_strAppLoc = m_strAppLoc.Left ( m_strAppLoc.ReverseFind(_T('\\') ) );
m_strAppDir = m_strAppLoc.Right( m_strAppLoc.GetLength() - m_strAppLoc.ReverseFind(_T('\\') ) );
and then I write to the registry the path to the application like this:
_tcscpy( lpszData, m_strAppLoc);
dwDataSize = _tcslen(lpszData) * sizeof(TCHAR);
if (ERROR_SUCCESS != (lReturn = RegSetValueEx( hKey, _T("Location"), 0, REG_SZ, (BYTE * const)lpszData, dwDataSize)) )
this is all working just fine.
My problem is that, due to a customization we've done for a customer, we now have two .BAT files which we want to use to load the app rather than allowing them to click the EXE directly, the BAT files simply put in place a particular version of the INI.
Anyway, I'm finding that when launched from a BAT file, my m_strAppLoc = __targv; is empty, and as such, the value for path is written as empty to the registry and then the app can't load properly the next time.
Is there a way to modify my BAT file so that the path will be parsed properly by the existing code? We need to do this w/o making a new software build.