config files for exe's that are called with a batch

This is a discussion on config files for exe's that are called with a batch within the Windows Programming forums, part of the Platform Specific Boards category; hi i have the folowing problem: i wrote a small comandline programm, that works on textfiles. it's behavior can be ...

  1. #1
    Registered User stormbringer's Avatar
    Join Date
    Jul 2002
    Posts
    90

    config files for exe's that are called with a batch

    hi

    i have the folowing problem: i wrote a small comandline programm, that works on textfiles. it's behavior can be configured in a file called keywords.cfg. this file shall be in the same directory as the exe (named cc.exe).
    the problem now ist, that if working in another dir (e.g. c:\temp) this programm is looking for the configfile in the curent working directory:

    Code:
    if((fkey=fopen("keywords.cfg","r"))==NULL)
       printf("\"keywords.cfg\" not found.");
    else {
       ...
    }
    I usuali solved this by simply searching in all the folders which are namend in the path variable. but this wan't do here, because the file won't be in a directory anywhere in the path. it will be called by a batch.
    so what i would need, is the path to the cc.exe. but how can i get this?

    thanks

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Specify the full pathname to your configuration file, if it will be in the same directory as the module, and you cannot be sure where the module is, you can use the GetModuleFileName() API routine to get it.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User stormbringer's Avatar
    Join Date
    Jul 2002
    Posts
    90
    That was what i was looking for such a long time.
    Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. calling batch files
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 04-18-2002, 11:11 AM
  2. Help with Header/Make files
    By Unregistered in forum C Programming
    Replies: 0
    Last Post: 04-10-2002, 11:57 PM
  3. reinserting htm files into chm help files
    By verb in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2002, 09:35 AM
  4. batch files
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-28-2001, 01:01 PM
  5. displaying text files, wierd thing :(
    By Gades in forum C Programming
    Replies: 2
    Last Post: 11-20-2001, 05:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21