在编程过程中,常常需要获取程序的路径,并对路径进行分解和合并,这时就使用到了_splitpath。同时与之相反的功能函数有:_makepath。与之相关的函数有:FindFirstFile等。

void _splitpath( const char *path, char *drive, char *dir, char *fname, char *ext );

分解路径,把你的完整路径给分割开来,就是一个对字符串进行分割的函数path, Full path(完整路径)
drive , Optional drive letter, followed by a colon (:)(磁盘驱动包含:)
dir, Optional directory path, including trailing slash. Forward slashes (/ ), backslashes (\ ), or both may be used.(文件路径,无论是以“/”,“\”)
fname, Base filename (no extension)(文件名)
ext , Optional filename extension, including leading period (.)(后缀名)

相关函数:

1、与之相反的为:_makepath,实现生成路径的功能。
2、FindFirstFile函数:到一个文件夹(包括子文件夹)去搜索指定文件。

 例如:

char szAppName[128] = {0};
GetModuleFileName(NULL, szAppName, 128);  //获取应用程序完整名称
char szDriver[128] = {0};
char szDir[128] = {0};
char szName[128] = {0};
char szExt[128] = {0};
_splitpath(szAppName, szDriver, szDir, szName, szExt); //分解目录

 

相关文章:

  • 2022-01-15
  • 2021-12-01
  • 2022-02-16
  • 2022-12-23
  • 2021-07-18
  • 2021-08-09
  • 2022-12-23
猜你喜欢
  • 2022-02-24
  • 2021-12-02
  • 2021-12-15
  • 2022-12-23
  • 2021-08-05
  • 2022-12-23
相关资源
相似解决方案