0
使用链路上可用的代码的快捷方式:一个使用命令行参数 http://msdn.microsoft.com/en-us/library/aa969393.aspx创建命令行参数
HRESULT CreateLink(LPCWSTR lpszPathObj1, 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(lpszPathObj1);
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;
}
我想在桌面上建立一个快捷方式,与目标(EXE)。 我试图设定目标在以下几个方面:
LPCWSTR lpszPathObj1 = L"C:/Folder1/Folder2/SomeApp.exe 690080776072629&734078";
创建快捷方式与目标:
"C:/Folder1/Folder2/SomeApp.exe 690080666072629&782078"
而且
LPCWSTR lpszPathObj1 = L"C:/Folder1/Folder2/SomeApp.exe\" 690080776072629&734078";
创建空白目标快捷方式。
我试过更多的选择,但没有工作。有人可以帮忙吗?
你试过了什么?我不认为分配给'LPCWSTR'会创建一个快捷方式(即显示您使用的代码) –
我使用的代码来自链接:http://msdn.microsoft.com/en-us/ library/aa969393.aspx – eeerahul
@eeerahul - 该页面上有多个样本,其中没有一个具有名为'lpszPathObj1'的变量。请显示您*使用的代码。 –