我用不同的dll实现多语言资源,但是在切换语言时,不能动态的加载语言资源dll.
每次都要重新启动程序,请问能否不重新启动程序,实现动态的加载语言资源dll。

解决方案 »

  1.   

    动态包含dll
    LoadLibrary(...)
    FreeLibrary(...)
      

  2.   

    现在代码如下
    char szProgramPath[512] = {0};
    if (GetModuleFileName(NULL, szProgramPath, 
    sizeof(szProgramPath)/sizeof(char)-1) != 0)
    {
    char *pchSplit = strrchr(szProgramPath, '\\');
    if (pchSplit != NULL)
    memset(pchSplit, 0, strlen(pchSplit)); string strLanguage;
    strLanguage = GetReg(ADMIN_REGKEYNAME, "Language");
    if (strcmp(strLanguage.c_str(), "chinese_gb") == 0)
    {
    strcat(szProgramPath, "\\language\\chinese_gb.dll");
    hResourceDll = LoadLibrary(szProgramPath);
    }
    else if (strcmp(strLanguage.c_str(), "chinese_big5") == 0)
    {
    strcat(szProgramPath, "\\language\\chinese_gb.dll");
    hResourceDll = LoadLibrary(szProgramPath);
    }
    else
    hResourceDll = NULL; if (hResourceDll)
    {
    AfxSetResourceHandle(hResourceDll);
    strcpy(szLanguage, strLanguage.c_str());
    }
    else
    strcpy(szLanguage, "english"); }
    else
    {
    strcpy(szLanguage, "english");
    }
      

  3.   

    AfxSetResourceHandle(hResourceDll);
    加载的资源如何卸载?
      

  4.   

    一个完整的例子http://www.codeproject.com/cpp/mult_lang_support.asp