Re: Current Folder PROGRAM is Running

From: suhredayan (suhredayan_at_NOSPAM.gmPUTaHEREil.com)
Date: 12/10/04


Date: Fri, 10 Dec 2004 09:51:43 +0530

Use 'DWORD GetCurrentDirectory()' for your code to work on wider flavours of
windows.

Thanks
Suhredayan Panikkal

"Mark Randall" <strike@rapiercom.freeserve.co.uk> wrote in message
news:eDZQUHm3EHA.3236@TK2MSFTNGP15.phx.gbl...
> Yes,
>
> Sorry about that.
>
> char *_getcwd(
> char *buffer,
> int maxlen
> );
>
> From MSDN:
>
> // GETCWD.C
> /* This program places the name of the current directory in the
> * buffer array, then displays the name of the current directory
> * on the screen. Specifying a length of _MAX_PATH leaves room
> * for the longest legal path name.
> */
>
> #include <direct.h>
> #include <stdlib.h>
> #include <stdio.h>
>
> void main( void )
> {
> char buffer[_MAX_PATH];
>
> /* Get the current working directory: */
> if( _getcwd( buffer, _MAX_PATH ) == NULL )
> perror( "_getcwd error" );
> else
> printf( "%s\n", buffer );
> }
>
>
>
> "Borek" <borek@bpp.your.pants.com.pl> wrote in message
> news:41b8e390@news.home.net.pl...
> > Mark Randall wrote:
> >
> >> > How can I get the current folder my program is running?
> >> > What function from Windows API?!
> >
> >> GetModuleFileName(AfxGetInstanceHandle(), path, _MAX_PATH);
> >
> > No way - that's the directory where the exe is located, not the current
> > directory...
> >
> > Look for _getcwd() function, which is not from Windows API, but works.
> > AFAIR #include <directory.h> or something like that.
> >
> > Best,
> > Borek
> >
> >
> > --
> > BPP Marcin Borkowski, ul. Architektów 14, 05-270 Marki
> > If you know someone with dyslexia take a look at http://www.bpp.com.pl
> > Remove your.pants to email me directly :)
>
>



Relevant Pages

  • Re: Im a C++ programmer, and Relfs X.CPP is good.
    ... void write_path(char* hm_path, char hm_buf); ... void list_contents(int argc, char** argv); ... Makes sure the user has specified an alpha buffer. ...
    (comp.lang.lisp)
  • Re: Im a C++ programmer, and Relfs X.CPP is good.
    ... void write_path(char* hm_path, char hm_buf); ... void list_contents(int argc, char** argv); ... Makes sure the user has specified an alpha buffer. ...
    (comp.unix.programmer)
  • Re: Replacing fgets
    ... One more pointer is that if I use mmap it will solve my problem that is ... on SCO UNIX and on windows. ... char *buffer = 0; ... //Total Buffer Length ...
    (comp.lang.c)
  • Re: Replacing fgets
    ... One more pointer is that if I use mmap it will solve my problem that is ... on SCO UNIX and on windows. ... char *buffer = 0; ... //Total Buffer Length ...
    (comp.lang.c)
  • (Not) Echoing Input in Secondary DOS Windows
    ... windows, something is not being done to make ... void gotoXY(int X, int Y); ... // source screen buffer ...
    (microsoft.public.vc.language)

Loading