各位大哥,和我说一下如何取得一个文件的物理路径!!!!?

解决方案 »

  1.   

    TCHAR chFilePath[MAX_PATH];
    GetModuleFileName(NULL,chFilePath,MAX_PATH);
    (_tcsrchr(chFilePath,'\\'))[1] = 0;
      

  2.   


    #include <stdlib.h>
    #include <stdio.h>void main( void )
    {
       char path_buffer[_MAX_PATH];
       char drive[_MAX_DRIVE];
       char dir[_MAX_DIR];
       char fname[_MAX_FNAME];
       char ext[_MAX_EXT];   _makepath( path_buffer, "c", "\\sample\\crt\\", "makepath", "c" );
       printf( "Path created with _makepath: %s\n\n", path_buffer );
       _splitpath( path_buffer, drive, dir, fname, ext );
       printf( "Path extracted with _splitpath:\n" );
       printf( "  Drive: %s\n", drive );
       printf( "  Dir: %s\n", dir );
       printf( "  Filename: %s\n", fname );
       printf( "  Ext: %s\n", ext );
    }
      

  3.   

    char szCurPath[200];

    //GetCurrentDirectory( 100, szCurPath ); /* 得到当前目录 */]
    memset(szCurPath, 0, 200);
    GetModuleFileName(NULL, szCurPath, sizeof(szCurPath));
      

  4.   

    GetModuleFileName是干八什么用的?