怎样取得应用程序路径?

解决方案 »

  1.   

    CString str;
    GetModuleFileName(NULL, str.GetBuffer(MAX_PATH), MAX_PATH);
    str.ReleaseBuffer();
    int n = str.ReverseFind('\\');
    str = str.Left(n);
      

  2.   

    char ProgramPath[ _MAX_PATH ];
    GetCurrentDirectory (256,ProgramPath ) ;
      

  3.   

    CString strAppPath;
    CString strTemp;
    ::GetModuleFileName( NULL, strTemp.GetBuffer( 256 ), 256 );
    strTemp.ReleaseBuffer();
    int nNum = strTemp.ReverseFind( '\\' );
    strAppPath = strTemp.Left( nNum );
    TCHAR c = strAppPath.GetAt( nNum - 1 );
    if( c == '\\' )
    {
    strAppPath += "";
    }
    else
    {
    strAppPath += "\\";
    }