2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 #include <afs/param.h>
28 * ROUTINES ___________________________________________________________________
32 void Shortcut_Init (void)
38 void Shortcut_Exit (void)
44 BOOL Shortcut_Create (LPTSTR pszTarget, LPCTSTR pszSource, LPTSTR pszDesc, LPTSTR pszArgs)
47 HRESULT rc = CoCreateInstance (CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
51 rc = psl->QueryInterface (IID_IPersistFile, (void **)&ppf);
54 rc = psl->SetPath (pszSource);
57 rc = psl->SetDescription (pszDesc ? pszDesc : pszSource);
61 rc = psl->SetArguments (pszArgs);
65 rc = ppf->Save (pszTarget, TRUE);
68 MultiByteToWideChar (CP_ACP, 0, pszTarget, -1, wsz, MAX_PATH);
69 rc = ppf->Save (wsz, TRUE);
78 return SUCCEEDED(rc) ? TRUE : FALSE;
82 void Shortcut_FixStartup (LPCTSTR pszLinkName, BOOL fAutoStart)
84 TCHAR szShortcut[ MAX_PATH + 10 ] = TEXT("");
87 if (RegOpenKey (HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"), &hk) == 0)
89 DWORD dwSize = sizeof(szShortcut);
90 DWORD dwType = REG_SZ;
91 RegQueryValueEx (hk, TEXT("Common Startup"), NULL, &dwType, (LPBYTE)szShortcut, &dwSize);
92 if (szShortcut[0] == TEXT('\0'))
94 dwSize = sizeof(szShortcut);
96 RegQueryValueEx (hk, TEXT("Startup"), NULL, &dwType, (LPBYTE)szShortcut, &dwSize);
100 if (szShortcut[0] == TEXT('\0'))
102 GetWindowsDirectory (szShortcut, MAX_PATH);
103 lstrcat (szShortcut, TEXT("\\Start Menu\\Programs\\Startup"));
105 lstrcat (szShortcut, TEXT("\\"));
106 lstrcat (szShortcut, pszLinkName);
108 TCHAR szSource[ MAX_PATH ];
109 GetModuleFileName (GetModuleHandle(NULL), szSource, MAX_PATH);
113 Shortcut_Create (szShortcut, szSource, "Autostart Authentication Agent");
115 else // (!g.fAutoStart)
117 DeleteFile (szShortcut);