|
-
Sep 16th, 2000, 05:56 AM
#1
Thread Starter
Addicted Member
Hello!
How can I retrieve current dir (where my EXE is placed, like in vb App.Path)?
And which are alternatives of Left() and Right() VB function in VC++?
Zvonko Bostjancic
Ilirska Bistrica, Slovenia
[email protected]
Using VS6 Professional with SP3
Programming mostly in VB and I've started to learn VC++ & MFC
-
Sep 16th, 2000, 09:26 AM
#2
Monday Morning Lunatic
When you start a console app (using main), argv[0] contains the full path and filename of your executable, for example c:\myprog\myprogram.exe.
To use equivalents of Left and Right, simply use strncpy in this way:
Code:
char *pcSrc = "Hello World";
char *pcDest = new char[length+1];
strncpy(pcDest, pcSrc+offset, length);
pcDest[length] = 0; // Terminator
This code reproduces Left. To use Right, you'd have to count backwards from the end of the string.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 16th, 2000, 09:47 AM
#3
Thread Starter
Addicted Member
I'm developing a MFC app.
Is argv[0] the same in MFC as in console app or do I have to do something else?
Zvonko Bostjancic
Ilirska Bistrica, Slovenia
[email protected]
Using VS6 Professional with SP3
Programming mostly in VB and I've started to learn VC++ & MFC
-
Sep 16th, 2000, 11:05 AM
#4
Guru
You can use the GetCurrentDirectory function in Win32/MFC apps.
Code:
TCHAR tcCurDir[MAX_PATH];
GetCurrentDirectory(MAX_PATH, tcCurDir);
// tcCurDir now contains the current directory.
// At least, it should be. :rolleyes:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|