0

I have written a little interpreter which can run scripts. For convenience, I associated the file type (.apol) with my interpreter located in "C:\Apol\Interpeter.exe" so whenever I double click a .apol file the Script interpreter will pop up and run this file.

but heres my problem. lets assume my script looks like following:

f = openfile("data.txt") //pseudocode

of course, windows will look in the directory of "C:\Apol\" first for this file, but what I actually want, is that windows will look in the directory of my Scipt file instead of my Interpreter, is this somehow possible to set up?

Moritz Schöfl
  • 763
  • 2
  • 7
  • 19
  • http://stackoverflow.com/a/1746519/2176845 – levengli Jul 17 '13 at 12:28
  • Are you sure? I happen to have a script interpreter as well and I've just tested it and found the current working directory to be the script path, not the location of the interpreter – Ingo Leonhardt Jul 17 '13 at 12:34
  • Maybe its the way my interpreter is written :( Ive fixed it with _chdir(path) which changes the working directory to some path (in my case the script) – Moritz Schöfl Jul 17 '13 at 12:47

1 Answers1

0

You will probably want to use Universal Naming Convention Path Syntax in your call to fopen. See fopen file from windows network location

Also you will want to find out about the script file the user clicked on, where that is located:

int
WINAPI
WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nShowCmd
    );

The lpCmdLine has that information for you.

Community
  • 1
  • 1
user2587106
  • 315
  • 1
  • 5