• 大小: 129KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: 其他
  • 标签: Windows7  开发  Windwos7  

资源简介

Windows 7程序开发系列之二(JumpList篇2 - Destination)的源代码。 教程地址:http://blog.csdn.net /ntwilford

资源截图

代码片段和文件信息


#include “FileRegistration.h“

#include 
#include 
#include 

HRESULT RegSetString(HKEY hkey PCWSTR pszSubKey PCWSTR pszValue PCWSTR pszData)
{
    size_t lenData = lstrlen(pszData);
    return HRESULT_FROM_WIN32(SHSetValue(
hkey pszSubKey pszValue REG_SZ pszData static_cast((lenData + 1) * sizeof(*pszData))));
}

HRESULT RegisterProgID(LPCWSTR lpszProgID BOOL fRegister)
{
    HRESULT hr;
    if (fRegister)
    {
        HKEY hkeyProgID;
        hr = HRESULT_FROM_WIN32(RegCreateKeyEx(HKEY_CLASSES_ROOT lpszProgID 0 NULL REG_OPTION_NON_VOLATILE
            KEY_SET_VALUE | KEY_CREATE_SUB_KEY  NULL &hkeyProgID NULL));
        if (SUCCEEDED(hr))
        {
            hr = RegSetString(hkeyProgID NULL L“FriendlyTypeName“ L“Custom Jump List Document“);
            if (SUCCEEDED(hr))
            {
                WCHAR szAppPath[MAX_PATH];
                hr = (GetModuleFileName(NULL szAppPath ARRAYSIZE(szAppPath)) > 0) ? S_OK : HRESULT_FROM_WIN32(GetLastError());
                if (SUCCEEDED(hr))
                {
                    WCHAR szIcon[MAX_PATH + 3];
                    hr = StringCchPrintf(szIcon ARRAYSIZE(szIcon) L“%s0“ szAppPath);
                    if (SUCCEEDED(hr))
                    {
                        hr = RegSetString(hkeyProgID L“DefaultIcon“ NULL szIcon);
                        if (SUCCEEDED(hr))
                        {
                            hr = RegSetString(hkeyProgID L“CurVer“ NULL lpszProgID);
                            if (SUCCEEDED(hr))
                            {
                                HKEY hkeyShell;
                                hr = HRESULT_FROM_WIN32(RegCreateKeyEx(hkeyProgID L“shell“ 0 NULL REG_OPTION_NON_VOLATILE
                                    KEY_SET_VALUE | KEY_CREATE_SUB_KEY NULL &hkeyShell NULL));
                                if (SUCCEEDED(hr))
                                {
                                    WCHAR szCmdLine[MAX_PATH * 2];
                                    hr = StringCchPrintf(szCmdLine ARRAYSIZE(szCmdLine) L“%s %%1“ szAppPath);
                                    if (SUCCEEDED(hr))
                                    {
                                        hr = RegSetString(hkeyShell L“Open\\Command“ NULL szCmdLine);
                                        if (SUCCEEDED(hr))
                                        {
                                            hr = RegSetString(hkeyShell NULL NULL L“Open“);
                                        }
                                    }
                                    RegCloseKey(hkeyShell);
                                }
                            }
                        }
                    }
                }
            }
            RegCloseKey(hkeyProgID);
        }
    }
    else
    {
        long lRes = RegDeleteTree(HKEY_CLAS

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2010-06-03 23:44  JumpList2\
     目录           0  2010-06-03 23:44  JumpList2\JumpList2\
     文件      238787  2010-06-03 21:19  JumpList2\JumpList2\APP.ico
     文件        5634  2010-06-03 22:58  JumpList2\JumpList2\FileRegistration.cpp
     文件         355  2009-08-13 05:40  JumpList2\JumpList2\FileRegistration.h
     文件        1686  2010-06-03 21:19  JumpList2\JumpList2\JumpList2.rc
     文件        4289  2010-06-03 22:47  JumpList2\JumpList2\JumpList2.vcproj
     文件        1417  2010-06-03 23:42  JumpList2\JumpList2\JumpList2.vcproj.wilford-NB.wilford.user
     文件        4286  2010-06-03 23:43  JumpList2\JumpList2\main.cpp
     文件         497  2010-06-03 21:19  JumpList2\JumpList2\resource.h
     文件           0  2010-06-03 23:38  JumpList2\JumpList2\TestFile1.txt
     文件           0  2010-06-03 23:38  JumpList2\JumpList2\TestFile2.txt
     文件           0  2010-06-03 23:38  JumpList2\JumpList2\TestFile3.txt
     文件         893  2010-06-03 21:01  JumpList2\JumpList2.sln
     文件       10240  2010-06-03 23:27  JumpList2\JumpList2.suo

评论

共有 条评论