C++ concat LPCTSTR

jon*_*ers 1 c++ string windows-ce lpcstr

我正在为WindowsCE CAB文件实现自定义操作,我需要连接LPCTSTR以获取到exe的正确路径.

我的自定义操作接收LPCTSTR作为参数.

所以(伪代码):

extern "C" codeINSTALL_EXIT MYCUSTOMACTION_API Install_Exit(
    HWND    hwndParent,
    LPCTSTR pszInstallDir,
    WORD    cFailedDirs,
    WORD    cFailedFiles,
    WORD    cFailedRegKeys,
    WORD    cFailedRegVals,
    WORD    cFailedShortcuts
)
{
    if (FALSE == LaunchApp(pszInstallDir + "\\MyApp.exe"))
       ::MessageBox(hwndParent, L"Could not launch app!", L"Setup", MB_ICONINFORMATION );
    return codeINSTALL_EXIT_DONE;
}
Run Code Online (Sandbox Code Playgroud)

这是使用虚构的"+"运算符,我将使用我的标准语言C#.

我在C++方面的经验相对较少.为我的目的附加LPCTSTR的正确方法是什么?LaunchApp方法使用此类型作为参数.

另外,如果我想在MessageBox中显示生成的路径(用于调试目的),是否有快速转换为LPCWSTR的方法?

Cos*_*min 6

对于串联,请使用StringCchCat

TCHAR pszDest[260] = _T("");
StringCchCat(pszDest, 260, pszInstallDir); 
StringCchCat(pszDest, 260, _T("\\MyApp.exe"));
LaunchApp(pszDest);
Run Code Online (Sandbox Code Playgroud)