diff --git a/src/win32/Reg.cpp b/src/win32/Reg.cpp index d9af81bb..2d36578a 100644 --- a/src/win32/Reg.cpp +++ b/src/win32/Reg.cpp @@ -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 ); diff --git a/src/win32/Reg.h b/src/win32/Reg.h index 66ad1e2e..e095c747 100644 --- a/src/win32/Reg.h +++ b/src/win32/Reg.h @@ -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 ); diff --git a/src/win32/VBA.cpp b/src/win32/VBA.cpp index c08189f7..c05d2ba1 100644 --- a/src/win32/VBA.cpp +++ b/src/win32/VBA.cpp @@ -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; }