TextSweep

Artifact Content
Login

Artifact c8fc535a71203726a053bd4ac34c0b513d0ea396:


#include <Windows.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <tchar.h>
#include <tcl.h>
#include <tk.h>
 
int Tk_AppInit(Tcl_Interp *interp){

  if (Tcl_Init(interp) == TCL_ERROR) {
    return TCL_ERROR;
  }
  if (Tk_Init(interp) == TCL_ERROR) {
    return TCL_ERROR;
  }
  
  TCHAR exedir [MAX_PATH];

  
#if 0 
  GetModuleFileName(NULL, exedir, MAX_PATH);
  _tprintf("%s/n", exedir);
  PathRemoveFileSpec(exedir);
  _tprintf("%s/n", exedir);
#endif

  /*Get the module's full path, and set to the current working directory.*/
  if (!GetModuleFileName(NULL, exedir, MAX_PATH)) {

    TCHAR errmsg[512];
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0, GetLastError(),0,errmsg,1024,NULL);

    _tprintf( TEXT("The path is %s, and the error is %s/n"), exedir, errmsg );
  }


  if (!PathRemoveFileSpec(exedir)) {

    TCHAR errmsg[512];
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0, GetLastError(),0,errmsg,1024,NULL);
    _tprintf( TEXT("The target dir is %s, and the error is %s/n"), exedir, errmsg );
  }

  if (!SetCurrentDirectory(exedir)) {

    TCHAR errmsg[512];
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0, GetLastError(),0,errmsg,1024,NULL);
    _tprintf( TEXT("The working dir is %s, and the error is %s/n"), exedir,errmsg );
  }

  Tcl_EvalFile(interp,"textsweep.tcl");
 
  return TCL_OK;
}


int main(int argc, char **argv) {
  Tk_Main (argc, argv, Tk_AppInit);
  return 0;
} 


// gcc -o test.exe test.c -L/mingw/path/to/library/directory -ltcl86 -ltk86   -DTCL_THREADS=1