bertil
Member Since: 1997/06/27
Tech Certifications:

Provide a quick, creative biography in 140 characters or less.

More bio
Activity
Points this month0
Total points400
Questions:
Solutions: 2
Articles:
Videos:
Courses:
Posts:
Professional Background
No Professional Background shown
More
Education
No Education Background shown
More
Full Biography

Hi! I founf some code from Microsoft that creates a lnk-file.So i hope
you can write a program from thei code or if you don't program yourself try to find a frend or so to help you.

pszShortcutFile is the file that the shortcut will point to. •pszLink is the shortcut you are creating with a LNK extension. •pszDesc is the description of the file. This is the string "Shortcut to filename", where filename is the name of the shortcut target.



Because this function makes a call to CoCreateInstance, it is assumed that CoInitialize has already been called. As you can see in the following code, this function uses both the IPersistFile interface, for actually saving the shortcut in the system, and the IShellLink interface, for storing the path and the description of the shortcut target:

HRESULT CreateShortCut::CreateIt (LPCSTR pszShortcutFile, LPSTR pszLink,
LPSTR pszDesc)
{
HRESULT hres;
IShellLink *psl;

// Create an IShellLink object and get a pointer to the IShellLink
// interface (returned from CoCreateInstance).
hres = CoCreateInstance (CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (void **)&psl);
if (SUCCEEDED (hres))
{
IPersistFile *ppf;

// Query IShellLink for the IPersistFile interface for
// saving the shortcut in persistent storage.
hres = psl->QueryInterface (IID_IPersistFile, (void **)&ppf);
if (SUCCEEDED (hres))
{
WORD wsz [MAX_PATH]; // buffer for Unicode string

// Set the path to the shortcut target.
hres = psl->SetPath (pszShortcutFile);

if (! SUCCEEDED (hres))
AfxMessageBox ("SetPath failed!");

// Set the description of the shortcut.
hres = psl->SetDescription (pszDesc);

if (! SUCCEEDED (hres))
AfxMessageBox ("SetDescription failed!");

// Ensure that the string consists of ANSI characters.
MultiByteToWideChar (CP_ACP, 0, pszLink, -1, wsz, MAX_PATH);

// Save the shortcut via the IPersistFile::Save member function.
hres = ppf->Save (wsz, TRUE);

if (! SUCCEEDED (hres))
AfxMessageBox (“Save failed!”);

// Release the pointer to IPersistFile.
ppf->Release ();
}
// Release the pointer to IShellLink.
psl->Release ();
}
return hres;
}

More
Languages
No Languages shown

Level Progress

Current: Level 0
bertil needs 1,600 points to level up.
LVL 1
  • Overall
    0