这种问题很多人都问过
void CShortCutDlg::OnCreate()
{
// TODO: Add your control notification handler code here
char m_strWinDir[512];
long rval;
HKEY hKey;
DWORD dwType;
DWORD dwSize;
rval = RegOpenKeyEx(HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
NULL, KEY_QUERY_VALUE, &hKey);
if(rval == ERROR_SUCCESS)
{
dwSize = 512;
rval = RegQueryValueEx(hKey, "Programs", 0, &dwType, (LPBYTE)m_strWinDir, &dwSize);
rval = RegCloseKey(hKey);
strcat(m_strWinDir, "\\VC编程技巧");
CreateDirectory(m_strWinDir, NULL);
strcat(m_strWinDir, "\\VC编程技巧.lnk");
HRESULT hres;
IShellLink* psl;
// 取得指向IshellLink接口的指针
CoInitialize(NULL);
hres = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *)&psl);
if(SUCCEEDED(hres))
{
IPersistFile* ppf;
// 设置快捷对象路径,并增加描述
psl->SetPath("c:\\VCSkill\\VCSkill.exe");
psl->SetWorkingDirectory("c:\\VCSkill");
psl->SetDescription("VC编程技巧");
hres = psl->QueryInterface(IID_IPersistFile,
(LPVOID *)&ppf);
if(SUCCEEDED(hres))
{
WORD wsz[MAX_PATH];
// 字符串为ANSI格式
MultiByteToWideChar(CP_ACP, 0, m_strWinDir, -1,
wsz, MAX_PATH);
// 保存链接
hres = ppf->Save(wsz, TRUE);
ppf->Release();
}
psl->Release();
}
}
else
{
AfxMessageBox("创建程序组和快捷方式失败,请稍后自行创建!");
}
}
void CShortCutDlg::OnCreate()
{
// TODO: Add your control notification handler code here
char m_strWinDir[512];
long rval;
HKEY hKey;
DWORD dwType;
DWORD dwSize;
rval = RegOpenKeyEx(HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
NULL, KEY_QUERY_VALUE, &hKey);
if(rval == ERROR_SUCCESS)
{
dwSize = 512;
rval = RegQueryValueEx(hKey, "Programs", 0, &dwType, (LPBYTE)m_strWinDir, &dwSize);
rval = RegCloseKey(hKey);
strcat(m_strWinDir, "\\VC编程技巧");
CreateDirectory(m_strWinDir, NULL);
strcat(m_strWinDir, "\\VC编程技巧.lnk");
HRESULT hres;
IShellLink* psl;
// 取得指向IshellLink接口的指针
CoInitialize(NULL);
hres = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *)&psl);
if(SUCCEEDED(hres))
{
IPersistFile* ppf;
// 设置快捷对象路径,并增加描述
psl->SetPath("c:\\VCSkill\\VCSkill.exe");
psl->SetWorkingDirectory("c:\\VCSkill");
psl->SetDescription("VC编程技巧");
hres = psl->QueryInterface(IID_IPersistFile,
(LPVOID *)&ppf);
if(SUCCEEDED(hres))
{
WORD wsz[MAX_PATH];
// 字符串为ANSI格式
MultiByteToWideChar(CP_ACP, 0, m_strWinDir, -1,
wsz, MAX_PATH);
// 保存链接
hres = ppf->Save(wsz, TRUE);
ppf->Release();
}
psl->Release();
}
}
else
{
AfxMessageBox("创建程序组和快捷方式失败,请稍后自行创建!");
}
}
解决方案 »
- 如何检索数据库中的数据????????/
- 请教vc将窗口隐藏到托盘区的问题
- 请教异步的小问题
- 急急急!!CXimage类的一个问题!!
- 难道高手都去休假了?!
- 有没有一种对话框既可以选择文件又可以选择文件夹?
- 一个小问提哦^_^
- 关于用MFC开发ActiveX控件的问题_急在线等待。
- 进程间通信问题:一个进程PostMessage,另一个进程可以用PeekMessage接受到这个消息吗?
- 编程求解“一本 300 页的书,数字 1 在页码中总共出现了多少次”。。。
- 《windows网络编程技术》第8章中介绍了5个模型,在结尾说服务器端最好用重叠io或完成io,客户端最好用...都没有提到select模型,是不是selec模型较落后不用去学了可以跳过不看?请过来人给些意见,谢谢!
- 学计算机的有必要读博士吗?
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders 子键下, Programs项。
我也正想把这段代码贴上呢!还好还好……