473,566 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

get current path

kk
Can any function tell the compiled program executing path? after using the
program to open a file from MFC dialog box, the path changes. thks in
advance.
Nov 14 '05 #1
11 15278
"kk" <kk******@cuhk. edu.hk> writes:
Can any function tell the compiled program executing path? after using the
program to open a file from MFC dialog box, the path changes. thks in
advance.


We don't know. Your question doesn't seem to be about the C
programming language, so we can't answer it here. Try a newsgroup
where they talk about MFC (whatever that is).

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #2
kk wrote:
Can any function tell the compiled program executing path? after using the
program to open a file from MFC dialog box, the path changes. thks in
advance.

I have only dealt with the situation once and didn't find a solution to
grab the execution path "as the execution path". I did however, find a
way to grab the current path (though the call slips my mind right now
and it was done in Linux, not Windows), but you can grab the execution
path first thing, then let your program do whatever it needs to do, Msft
Foundation Classes not-with-standing.

TheMusikMan
Nov 14 '05 #3
kk wrote:
Can any function tell the compiled program executing path? after using the
program to open a file from MFC dialog box, the path changes. thks in
advance.

You
#include <direct.h>

....
_getcwd(int buflen, char *pathbuffer);

This will put the current path into pathbuffer up to buflen chars.

Then there is
_chdir(char *path);

that will set the current path to the given one.

One way to avoid changing the path is to get the path before
calling the file open dialog, then setting the path to the saved
one after the dialog exists.

But a more simpler way is to tell the program not to change the
path. The file open dialog has a flag to avoid changing the path
Look in the SDK documentation.

jacob
Nov 14 '05 #4
jacob navia <ja***@jacob.re mcomp.fr> writes:
kk wrote:
Can any function tell the compiled program executing path? after using the
program to open a file from MFC dialog box, the path changes. thks in
advance.

You
#include <direct.h>


I get:

direct.h: No such file or directory

There is no <direct.h> header in standard C. This is why we have
system-specific newsgroups.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #5
Keith Thompson wrote:
jacob navia <ja***@jacob.re mcomp.fr> writes:
kk wrote:
Can any function tell the compiled program executing path?

<snip>

direct.h: No such file or directory

There is no <direct.h> header in standard C. This is why we have
system-specific newsgroups.


What OS, etc are you running this on?

TheMusikMan
Nov 14 '05 #6
Keith Thompson wrote:
jacob navia <ja***@jacob.re mcomp.fr> writes:
kk wrote:
Can any function tell the compiled program executing path?


<snip/>

If you are running basically anything Windows, then the Windows API call
for current directory (according to Msft VS.NET) is as follows:

The GetCurrentDirec tory function retrieves the current directory for the
current process.
DWORD GetCurrentDirec tory(
DWORD nBufferLength,
LPTSTR lpBuffer
);

Parameters
nBufferLength
[in] Length of the buffer for the current directory string, in TCHARs.
The buffer length must include room for a terminating null character.
lpBuffer
[out] Pointer to the buffer that receives the current directory string.
This null-terminated string specifies the absolute path to the current
directory.
Return Values
If the function succeeds, the return value specifies the number of
characters written to the buffer, not including the terminating null
character.

If the function fails, the return value is zero. To get extended error
information, call GetLastError.

If the buffer pointed to by lpBuffer is not large enough, the return
value specifies the required size of the buffer, in characters,
including the null- terminating character.

<snipped remarks/>

Requirements
Client: Included in Windows XP, Windows 2000 Professional, Windows NT
Workstation, Windows Me, Windows 98, and Windows 95.
Server: Included in Windows Server 2003, Windows 2000 Server, and
Windows NT Server.
Unicode: Implemented as Unicode and ANSI versions. Note that Unicode
support on Windows Me/98/95 requires Microsoft Layer for Unicode.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Nov 14 '05 #7
TheMusikMan <mu********@acc ess-4-free.com> writes:
Keith Thompson wrote:
jacob navia <ja***@jacob.re mcomp.fr> writes:
kk wrote:

Can any function tell the compiled program executing path?


<snip>
direct.h: No such file or directory
There is no <direct.h> header in standard C. This is why we have
system-specific newsgroups.


What OS, etc are you running this on?


It really doesn't matter. The point, as I said, is that the is no
<direct.h> header in standard C. If there's one on your system,
that's fine, but you need to be aware that it's system-specific, and
that comp.lang.c isn't the place to discuss it.

(But since you ask, I get the same result on Cygwin under Windows XP,
on Solaris, and on Linux.)

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #8
TheMusikMan <mu********@acc ess-4-free.com> writes:
Keith Thompson wrote:
jacob navia <ja***@jacob.re mcomp.fr> writes:
kk wrote:

Can any function tell the compiled program executing path?


<snip/>

If you are running basically anything Windows, then the Windows API
call for current directory (according to Msft VS.NET) is as follows:

[snip]

Then the place to discuss it is comp.os.ms-windows.program mer.win32.
It's off-topic here.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #9
On Fri, 15 Oct 2004 06:21:34 GMT
Keith Thompson <ks***@mib.or g> wrote:
TheMusikMan <mu********@acc ess-4-free.com> writes:
Keith Thompson wrote:
jacob navia <ja***@jacob.re mcomp.fr> writes:

kk wrote:

> Can any function tell the compiled program executing path?


<snip/>

If you are running basically anything Windows, then the Windows API
call for current directory (according to Msft VS.NET) is as follows:

[snip]

Then the place to discuss it is comp.os.ms-windows.program mer.win32.
It's off-topic here.


<OT>
It is also technically incorrect since Win3.1 is also Windows as is
WinCE etc. Of course, no one here knows that ;-)
</OT>
--
Flash Gordon
Sometimes I think shooting would be far too good for some people.
Although my email address says spam, it is real and I read it.
Nov 14 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3318
by: gnah | last post by:
Greetings, I hope my problem is easy to fix, I'm pretty new with php - but I am getting weird results with the opendir() function. It may just be a path problem, but I don't see which variable to change. here are some tests I did to see what was wrong: $blah = opendir("blocks"); while ($file = readdir($blah)) {
1
2138
by: UncleStoner | last post by:
Using Javascript, you can call document.cookie to get a list of all the cookies that will be sent to the path of the current document. Is their a way to get all the cookies associated with the current domain without regard to the path of the current document? For example, if there is a cookie with path=/foo and a cookie with path=/bar, and...
11
21908
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a C# equivalent. Any ideas? -- ----------------------------------- Ken Varn Senior Software Engineer Diebold Inc. varnk@diebold.com
4
16357
by: Jon Rea | last post by:
Hi, Just a quickie ... I thought that Directory.GetCurrentGirectory(), unless the current directory had been changed by the program, would always point to the directory where the .exe for the program was. However, if my program is launched from the start menu in windows XP, Directory.GetCurrentGirectory() returns a special windows...
3
25647
by: PHaroZ | last post by:
Hi, I want to retrieve the complete full path to the directory of my current page but i don't find how to do that. For example i want : D:\myWebSite\firstDotNetWebApp\dir1\ I tried "AppDomain.CurrentDomain.BaseDirectory" but it's return only the path to my WebApplication, ex : D:\myWebSite\firstDotNetWebApp\
1
3606
by: Simon | last post by:
Dear Access friends, How can I load a string with his own folder address. The following code addressed to the system folder of MS programs.
3
3179
by: Chris Mellon | last post by:
This appears to be a change in behavior from Python 2.4 to Python 2.5, which I can't find documented anywhere. It may be windows only, or related to Windows behavior. In 2.4, the current directory (os.curdir) was on sys.path. In 2.5, it appears to be the base directory of the running script. For example, if you execute the file testme.py in...
11
6511
by: greg | last post by:
Hi all, Is there a way to get the current theme name at design time? I'm trying to write a custom control for which I need to use images from the current theme. I have asigned a theme to the page as well as in the web.config. The control looks ok at run time but when viewed in the Visual Studio designer it cannot pick up the current...
8
2126
by: =?Utf-8?B?R2VvcmdlQXRraW5z?= | last post by:
Greetings! I wrote a small Exe that simply runs Shell to load PowerPoint and launch a particular file, depending on the day of the week. However, it was set up for office 2003 (I naively hardcoded the path) and I also used Shell. Does anybody have a snipped showing a more efficient method for launching a Powerpoint file, regardless of which...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8108
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.