| |

VerySource

 Forgot password?
 Register
Search
View: 898|Reply: 7

How to get the path of the file?

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-13 21:00:01
| Show all posts |Read mode
How do I get the path to the application itself?
For example: test.exe is installed under C:\aaa\, how to get C:\aaa\when running test.exe?
Reply

Use magic Report

0

Threads

2

Posts

1.00

Credits

Newbie

Rank: 1

Credits
1.00

 China

Post time: 2020-3-16 20:13:10
| Show all posts
right click - attribute - position
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-6-10 14:15:01
| Show all posts
GetModuleFileName
Reply

Use magic Report

0

Threads

14

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-6-10 23:45:02
| Show all posts
//Get the path where the main program is, stored in sPath
CString sPath;
GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH);
sPath.ReleaseBuffer ();
Reply

Use magic Report

0

Threads

10

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-6-11 10:15:01
| Show all posts
GetModuleFileName
Or theApp.m_pszExeName
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-6-12 09:30:01
| Show all posts
Need to disassemble and then combine, use the following three functions
GetModuleFileName
_splitpath
_makepath
Reply

Use magic Report

0

Threads

11

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-6-15 23:45:01
| Show all posts
char buffer[100];
GetModuleFileName(NULL, buffer, 100);
    CString strpathname(buffer);
strpathname = strpathname.Mid(0,strpathname.ReverseFind('\\'));
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-6-24 11:00:01
| Show all posts
AfxGetAppPath()
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list