LPURL_COMPONENTS UrlComponents;
CString strTempUrl = "Directory%20_1/1B.htm";
//还原成Directory _1/1B.htm
InternetCrackUrl(strTempUrl,strTempUrl.GetLength(),ICU_DECODE,UrlComponents);//高手们帮我看一下

解决方案 »

  1.   

    URL_COMPONENTS UrlComponents;
    CString strTempUrl = "Directory%20_1/1B.htm";
    //还原成Directory _1/1B.htm
    InternetCrackUrl(strTempUrl,strTempUrl.GetLength(),ICU_DECODE,&UrlComponents);
      

  2.   

    按照MSDN上的说法写成:
    URL_COMPONENTS UrlComponents;
    CString strTempUrl = "Directory%20_1/1B.htm";
    UrlComponents.dwStructSize = sizeof(URL_COMPONENTS);
    //还原成Directory _1/1B.htm
    InternetCrackUrl(strTempUrl,strTempUrl.GetLength(),ICU_DECODE,&UrlComponents);
    最后InternetCrackUrl还是返回错误.
      

  3.   

    void CrackUrl()
    {
    URL_COMPONENTS uc;
    char Scheme[1000];
    char HostName[1000];
    char UserName[1000];
    char Password[1000];
    char UrlPath[1000];
    char ExtraInfo[1000]; uc.dwStructSize = sizeof(uc);
    uc.lpszScheme = Scheme;
    uc.lpszHostName = HostName;
    uc.lpszUserName = UserName;
    uc.lpszPassword = Password;
    uc.lpszUrlPath = UrlPath;
    uc.lpszExtraInfo = ExtraInfo; uc.dwSchemeLength = 1000;
    uc.dwHostNameLength = 1000;
    uc.dwUserNameLength = 1000;
    uc.dwPasswordLength = 1000;
    uc.dwUrlPathLength = 1000;
    uc.dwExtraInfoLength = 1000; InternetCrackUrl(
    "http://hoge:[email protected]:8080/masapico/api_sample.index",
    0, 0, &uc); printf("scheme: '%s'\n", uc.lpszScheme);
    printf("host name: '%s'\n", uc.lpszHostName);
    printf("port: %d\n", uc.nPort);
    printf("user name: '%s'\n", uc.lpszUserName);
    printf("password: '%s'\n", uc.lpszPassword);
    printf("url path: '%s'\n", uc.lpszUrlPath);
    printf("extra info: '%s'\n", uc.lpszExtraInfo);

    printf("scheme type: ");
    switch(uc.nScheme) {
    case INTERNET_SCHEME_PARTIAL: printf("partial.\n"); break;
    case INTERNET_SCHEME_UNKNOWN: printf("unknown.\n"); break;
    case INTERNET_SCHEME_DEFAULT: printf("default.\n"); break;
    case INTERNET_SCHEME_FTP: printf("FTP.\n"); break;
    case INTERNET_SCHEME_GOPHER: printf("GOPHER.\n"); break;
    case INTERNET_SCHEME_HTTP: printf("HTTP.\n"); break;
    case INTERNET_SCHEME_HTTPS: printf("HTTPS.\n"); break;
    case INTERNET_SCHEME_FILE: printf("FILE.\n"); break;
    case INTERNET_SCHEME_NEWS: printf("NEWS.\n"); break;
    case INTERNET_SCHEME_MAILTO: printf("MAILTO.\n"); break;
    default: printf("%d\n", uc.nScheme);
    }
    }