=================================================================== RCS file: /home/cvs/OpenXM_contrib2/windows/asir32gui/io.c,v retrieving revision 1.3 retrieving revision 1.6 diff -u -p -r1.3 -r1.6 --- OpenXM_contrib2/windows/asir32gui/io.c 2005/10/19 04:51:16 1.3 +++ OpenXM_contrib2/windows/asir32gui/io.c 2013/08/03 13:55:32 1.6 @@ -38,9 +38,9 @@ char *errmsg; LONG ret; HKEY hOpenKey; DWORD Type,dw; - char dir[BUFSIZ],message[BUFSIZ]; + char dir[BUFSIZ],message[BUFSIZ],engine[BUFSIZ]; char *slash; - int ldir; + size_t ldir; static char rootdir[BUFSIZ]; static int rootdir_is_initialized; @@ -49,12 +49,28 @@ char *errmsg; return TRUE; } + if(GetModuleFileName(NULL,dir,BUFSIZ)) { + slash = strrchr(dir,'\\'); + *slash = 0; + sprintf(engine,"%s\\engine.exe", dir); + if ( access(engine,0) >= 0 ) { + slash = strrchr(dir,'\\'); + if ( slash ) { + *slash = 0; + } + use_current_dir = 1; + strcpy(rootdir,dir); + strcpy(name,dir); + rootdir_is_initialized = 1; + return TRUE; + } + } GetCurrentDirectory(BUFSIZ,dir); slash = strrchr(dir,'\\'); if ( slash ) *slash = 0; ldir = strlen(dir)+1; - if ( 1 || access("UseCurrentDir",0) >= 0 ) { + if ( access("UseCurrentDir",0) >= 0 ) { use_current_dir = 1; strcpy(rootdir,dir); strcpy(name,dir); @@ -86,7 +102,7 @@ char *errmsg; NULL); return FALSE; } - if ( ret = RegSetValueEx(hOpenKey,"Directory",NULL,REG_SZ,dir,ldir) ) { + if ( ret = RegSetValueEx(hOpenKey,"Directory",0,REG_SZ,dir,ldir) ) { FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, @@ -164,9 +180,8 @@ BOOL Init_IO(char *errmsg) { if ( get_rootdir(name,len,errmsg) == FALSE ) { return FALSE; } -// sprintf(AsirExe,"%s\\bin\\engine.exe",name); + sprintf(AsirExe,"%s\\bin\\engine.exe",name); // sprintf(AsirExe,"c:\\home\\noro\\engine2000\\debug\\engine.exe"); - sprintf(AsirExe,"d:\\cygwin\\home\\noro\\OpenXM_contrib2\\\\windows\\engine2000\\debug\\engine.exe"); if ( !getenv("HOME") ) { sprintf(home,"HOME=%s",name); _putenv(home); @@ -260,19 +275,25 @@ void read_and_insert() } } +static char history_path[BUFSIZ]; +static char history_errmsg[BUFSIZ]; + void init_input_history() { + char rootdir[BUFSIZ]; + get_rootdir(rootdir,sizeof(rootdir),history_errmsg); + sprintf(history_path,"%s\\bin\\%s",rootdir,HISTORY); init_hist(MAXHIST); } void write_input_history() { - write_hist(HISTORY); + write_hist(history_path); } void read_input_history() { - read_hist(HISTORY); + read_hist(history_path); } void send_intr() {