-
-
[原创]添加右键菜单 小工具
-
发表于:
2013-4-19 13:54
3891
-
CString strKey = L"*\\shell\\";
HKEY hKey = NULL;
DWORD dwRead;
DWORD dwRet;
strKey += m_strName;
dwRet = RegCreateKeyEx(HKEY_CLASSES_ROOT, strKey, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwRead);
if(dwRet != ERROR_SUCCESS)
{
return FALSE;
}
TRACE(L"%d, %d", _tcslen(m_strLnkName), m_strLnkName.GetLength());
dwRet = RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)m_strLnkName.GetBuffer(), ((DWORD)_tcslen(m_strLnkName) + 1)*2);
if(dwRet != ERROR_SUCCESS)
{
return FALSE;
}
RegCloseKey(hKey);
hKey = NULL;
strKey += L"\\Command";
dwRet = RegCreateKeyEx(HKEY_CLASSES_ROOT, strKey, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwRead);
if(dwRet != ERROR_SUCCESS)
{
RegCloseKey(hKey);
return FALSE;
}
CString strTmp;
strTmp += L"\"";
strTmp += m_strPath;
strTmp += L"\" \"%1\""; //后面添加 "%1"不知道是为什么
dwRet = RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)strTmp.GetBuffer(), ((DWORD)_tcslen(strTmp) + 1)*2);
if(dwRet != ERROR_SUCCESS)
{
RegCloseKey(hKey);
return FALSE;
}
RegCloseKey(hKey);
return TRUE;
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!