Add new command line switch: "--configpath YOURPATHHERE"

This commit is contained in:
spacy51 2009-08-18 20:32:26 +00:00
parent 3162c1554e
commit 08bd48b812
3 changed files with 35 additions and 20 deletions

View File

@ -10,7 +10,7 @@ static CString *regVbaPath = NULL;
bool regEnabled = true;
void regInit(const char *path)
void regInit(const char *path, bool force)
{
if( regEnabled ) {
DWORD disp = 0;
@ -32,7 +32,7 @@ void regInit(const char *path)
// If vba.ini exists in executable's folder, use it. Else create/use one in %appdata% folder.
regVbaPath = new CString();
regVbaPath->Format(MakeInstanceFilename("%s\\vba.ini"), path);
if( !utilFileExists( regVbaPath->GetString() ) ) {
if( !force && !utilFileExists( regVbaPath->GetString() ) ) {
TCHAR appdata[MAX_PATH+1];
SHGetFolderPath( NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdata );
regVbaPath->Format( "%s\\VBA-M", appdata );

View File

@ -10,7 +10,7 @@ void regSetStringValue(const char *key,const char *value);
void regSetDwordValue(const char *key,DWORD value,bool force=false);
void regSetBinaryValue(const char *key, char *value, int count);
void regDeleteValue(char *key);
void regInit(const char *);
void regInit(const char *, bool force = false);
void regShutdown();
bool regCreateFileType( const char *ext, const char *type );
bool regAssociateType( const char *type, const char *desc, const char *application, const char *icon = NULL );

View File

@ -443,7 +443,32 @@ BOOL VBA::InitInstance()
if(!InitLink())
return FALSE;;
regInit(winBuffer);
bool force = false;
if (m_lpCmdLine[0])
{
if(__argc > 0) {
if( 0 == strcmp( __argv[1], "--configpath" ) ) {
if( __argc > 2 ) {
strcpy( winBuffer, __argv[2] );
force = true;
if( __argc > 3 ) {
szFile = __argv[3]; filename = szFile;
int index = filename.ReverseFind('.');
if(index != -1)
filename = filename.Left(index);
}
}
} else {
szFile = __argv[1]; filename = szFile;
int index = filename.ReverseFind('.');
if(index != -1)
filename = filename.Left(index);
}
}
}
regInit(winBuffer, force);
loadSettings();
@ -480,22 +505,12 @@ BOOL VBA::InitInstance()
winAccelMgr.UpdateMenu(menu);
if (m_lpCmdLine[0])
{
if(__argc > 0) {
szFile = __argv[1];
filename = szFile;
}
int index = filename.ReverseFind('.');
if(index != -1)
filename = filename.Left(index);
if(((MainWnd*)m_pMainWnd)->FileRun())
emulating = true;
else
emulating = false;
}
if( !filename.IsEmpty() ) {
if(((MainWnd*)m_pMainWnd)->FileRun())
emulating = true;
else
emulating = false;
}
return TRUE;
}