我想替换根据上述函数的路径得到的可执行程序的路径,变为同目录下另一个程序的名称.如何替换?
因为在动态库中,使用CString类出现了问题,
<1>添加了#include <Afxext.h> 和#include <afxwin.h> 提示windows结构已经定义过,等错误.
<2>后来该project->Settings中,使用USing MFC in Shared DLL ,结果提示
    error LNK2005: _DllMain@12 already defined in MainLib.obj
    fatal error LNK1169: one or more multiply defined symbols found

解决方案 »

  1.   

    如果在控制台下用CString,還需要設定多線程支持。不用CString可以用char型數組啊,只是字符串而已。
      

  2.   

    CString strPath;
    int nPos=strPath.ReverseFind('\\');
    strPath=strPath.Left(nPos+1);
    shang上述过程如何完成?
      

  3.   

    char str[260]="c:\\a\\b\\c.exe";
    char des[260]="";
    char *s;
    s=strrchr(str,'\\');
    memmove(des,str,s-str);
    cout<<des<<endl;
      

  4.   

    char lpszPathName[MAX_PATH];
    memset(lpszPathName, 0x0, sizeof(lpszPathName));
    ::GetModuleFileName(::AfxGetInstanceHandle(), lpszPathName, MAX_PATH);
    GetModuleFileName不让用了????
      

  5.   

    error C2065: 'AfxGetInstanceHandle' : undeclared identifier
      

  6.   

    不行的
    添加后,就提示windows结构已经定义过了
      

  7.   

    將#include "windows.h"放到其它包含的後面。
      

  8.   

    其實第一個參數設成NULL就可以了。