Sorry,my computer doesn't support Chinese IME.But you can answer it in Chinese.

解决方案 »

  1.   

    GetModuleFileName(NULL,filepath,MAX_PATH);The GetModuleFileName function retrieves the full path and file name for the file containing the specified module. Windows 95/98: The GetModuleFilename function retrieves long file names when an application's version number is greater than or equal to 4.00 and the long file name is available. Otherwise, it returns only 8.3 format file names.DWORD GetModuleFileName(
      HMODULE hModule,    // handle to module
      LPTSTR lpFilename,  // file name of module
      DWORD nSize         // size of buffer
    );
    Parameters
    hModule 
    [in] Handle to the module whose file name is being requested. If this parameter is NULL, GetModuleFileName returns the path for the file containing the current process. 
    lpFilename 
    [out] Pointer to a buffer that receives the path and file name of the specified module. 
    nSize 
    [in] Specifies the length, in TCHARs, of the lpFilename buffer. If the length of the path and file name exceeds this limit, the string is truncated. 
      

  2.   

    GetCurrentDirectoryFrom MSDN:
    The GetCurrentDirectory function retrieves the current directory for the current process. DWORD GetCurrentDirectory(
      DWORD nBufferLength,  // size, in characters, of directory buffer
      LPTSTR lpBuffer       // pointer to buffer for current directory
    );
      

  3.   

    如何获得应用程序的全路径(包括可执行文件名)?
    对于Win32应用程序来讲,获得可执行文件的路径其实十分简单,只要调用__argv[0]即可。下面的代表你可以加在任何地方,都会看到你的应用程序名:AfxMessageBox(__argv[0]);
      

  4.   

    you can use __argv[ 0 ] in any where
      

  5.   

    只想或得路径而不包括文件名的话:CString GetExeDirectory()
    {
    char *szCmd=NULL,*pc=NULL; 
    int nPathLen=0; 
    char *szPath=NULL;
    CString m_ExeDir;

    szCmd=GetCommandLine(); if (szCmd[0]!='\"') return ""; 

    for (pc=szCmd+1; *pc; pc++)
    if (*pc=='\"') break; 

    for (  ; pc>=szCmd+1; pc--)
    {
    if (*pc=='\\') break;
    if (*pc=='/') break;
    }

    nPathLen=pc-(szCmd+1);
    if (nPathLen<=0) return ""; 

    szPath=(char *)malloc(nPathLen+1); if (szPath==NULL) return "";
    memcpy(szPath,szCmd+1,nPathLen); szPath[nPathLen]=0;

    m_ExeDir=szPath;
    free(szPath); return m_ExeDir;
    }