VC creation shortcuts

Source: Internet
Author: User
Createshortcut (maid, maid)
{
Hresult hres;
Ishelllink * PSL;
 
// Get a pointer to the ishelllink interface.
Hres = cocreateinstance (clsid_shelllink, null, clsctx_inproc_server,
Iid_ishelllink, (lpvoid *) & PSL );
If (succeeded (hres ))
{
Ipersistfile * PPF;

// Set the path to the specified cut target and add the description.
Psl-> setpath (lpszpathobj );
Psl-> setdescription (lpszdesc );

// Query ishelllink for the ipersistfile interface for saving
// Export cut 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 );

// Todo: Check return value from multibytewidechar to ensure

// Save the link by calling ipersistfile: Save.
Hres = PPF-> Save (wsz, true );
PPF-> release ();
}
Psl-> release ();
}
Return hres;
}

Don't forget to call coinitialize (null) first.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.