2013-10-29 3 views
0

내가 가진이 포함오류 [C는 ++]

HRESULT CreateLink(LPCWSTR lpszPathObj, LPCSTR lpszPathLink, LPCWSTR lpszDesc){ 
    HRESULT hres; 
    IShellLink* psl; 

    // Get a pointer to the IShellLink interface. It is assumed that CoInitialize 
    // has already been called. 
    hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); 
    if (SUCCEEDED(hres)){ 
     IPersistFile* ppf; 

     // Set the path to the shortcut target and add the description. 
     psl->SetPath(lpszPathObj); 
     psl->SetDescription(lpszDesc); 

     // Query IShellLink for the IPersistFile interface, used for saving the 
     // shortcut in persistent storage. 
     hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf); 

     if (SUCCEEDED(hres)) 
     { 
      WCHAR wsz[MAX_PATH]; 

      // Ensure that the string is Unicode. 
      MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1, wsz, MAX_PATH); 

      // Add code here to check return value from MultiByteWideChar 
      // for success. 

      // Save the link by calling IPersistFile::Save. 
      hres = ppf->Save(wsz, TRUE); 
      ppf->Release(); 
     } 
     psl->Release(); 
    } 
    return hres; 
} 

하지만 이러한 컴파일 오류가납니다을 'IShellLinkA :: SetPath (const WCHAR * &)'호출 후보가 일치하지 않습니다. 가상 HRESULT IShellLinkA :: SetPath (const CHAR *)

동일한 오류가 발생합니다. 또는 setDescription를 들어, 분명히 그들은 그들의 실제 코드가없는 즉, 가상으로 프로그램되어

virtual HRESULT WINAPI SetPath(LPCSTR pszFile) = 0; 

내가 헤더 파일이나 뭔가가 있어야합니다,하지만 나는 단서가 없다. 나는 조금 길을 잃었 어. 나는 이런 오류가 없어야한다고 생각해. 어떤 아이디어? 대단히 감사합니다 .-

답변

0

Use Multi-Byte Character Set에서 Use Unicode Character Set으로 프로젝트 설정을 변경하십시오. 이 옵션은 프로젝트 기본값의 일반 구성 설정에 있습니다.

0

사용

psl->SetPath(CW2T(lpszPathObj)); 

당신이 MBCS 프로젝트가 있다면. 이 경우 SetPath에는 char *가 필요합니다. 이 표기법은 프로젝트를 유니 코드로 전환하더라도 항상 작동합니다.