GetCurrentDirectory ? Is it supposed to work ? 
Author Message
 GetCurrentDirectory ? Is it supposed to work ?

Hi folks !

GetCurrentDirectory  will sometimes return the correct path and sometimes
not. Instead of always giving C:\Program Files\AppName\" It will produce
"C:\"...

These variations occur during the same execution of the program.

I simply need to get the path where my app is running,... installed !

Thanks in advance !



Sun, 27 Mar 2005 02:38:23 GMT  
 GetCurrentDirectory ? Is it supposed to work ?
Try use GetModuleFilename instead. An application's current directory can be
affected by file open/save boxes (and is hard to really tell in a windowing
environment such as Windows).

Chris Burnette
EOIR Technologies


Quote:
> Hi folks !

> GetCurrentDirectory  will sometimes return the correct path and sometimes
> not. Instead of always giving C:\Program Files\AppName\" It will produce
> "C:\"...

> These variations occur during the same execution of the program.

> I simply need to get the path where my app is running,... installed !

> Thanks in advance !



Sun, 27 Mar 2005 02:51:26 GMT  
 GetCurrentDirectory ? Is it supposed to work ?
On Tue, 8 Oct 2002 14:38:23 -0400, "tutu lamotte"

Quote:

>I simply need to get the path where my app is running,... installed !

Try GetModuleFileName(NULL, buffer, size) and remove the filename from the end
of the returned string.

You might also consider posting to more appropriate newsgroups next time - eg
comp.os.ms-windows.programmer.win32

Jon



Sun, 27 Mar 2005 02:57:10 GMT  
 GetCurrentDirectory ? Is it supposed to work ?
To get the path of your app you can use GetModuleFileName(...).


Quote:
> Hi folks !

> GetCurrentDirectory  will sometimes return the correct path and sometimes
> not. Instead of always giving C:\Program Files\AppName\" It will produce
> "C:\"...

> These variations occur during the same execution of the program.

> I simply need to get the path where my app is running,... installed !

> Thanks in advance !



Sun, 27 Mar 2005 02:54:49 GMT  
 GetCurrentDirectory ? Is it supposed to work ?

Quote:

> Hi folks !

> GetCurrentDirectory  will sometimes return the correct path and sometimes
> not. Instead of always giving C:\Program Files\AppName\" It will produce
> "C:\"...

> These variations occur during the same execution of the program.

> I simply need to get the path where my app is running,... installed !

> Thanks in advance !

You're calling the wrong function.  "current directory" does not mean
"the path where my app is ... installed."  Call GetModuleFilename()
instead.

--
Scott McPhillips [VC++ MVP]



Sun, 27 Mar 2005 10:14:37 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. GetCurrentDirectory ? Is it supposed to work ?

2. GetCurrentDirectory ? Is it supposed to work ?

3. This is NOT supposed to work!!

4. CopyFile is'nt working the way it is supposed to

5. Am I working on the right lines... (long)

6. ifstream won't work or am i dumb

7. I am new to programming and am lost

8. Directory.GetCurrentDirectory();

9. GetCurrentDirectory failing

10. GetCurrentDirectory() in VC++ Console App

11. ::GetCurrentDirectory Question On Using

12. bug with vc++ and getcurrentdirectory

 

 
Powered by phpBB® Forum Software