VC实现创建快捷方式

    HRESULT hr  =  CoInitialize(NULL);

    
if  (SUCCEEDED(hr))
    
{
        IShellLink 
*pisl;
        hr 
= CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&pisl);

        
if (SUCCEEDED(hr))
        
{
            IPersistFile
* pIPF;
            pisl
->SetPath("c:\\windows\\notepad.exe");
            hr 
= pisl->QueryInterface(IID_IPersistFile, (void**)&pIPF);

            
if (SUCCEEDED(hr))
            
{
                pIPF
->Save(L"c:\\记事本.lnk", FALSE);
                pIPF
->Release();
            }


            pisl
->Release();
        }


        CoUninitialize();
    }

你可能感兴趣的:(VC实现创建快捷方式)