How to create a shortcut (transfer from CCRUN) in the quick start bar (original code)

zhaozj2021-02-16  55

How to create shortcuts in the fast boot bar #define no_win32_lean_and_mean # include #include // The above three rows are placed in unit files: ------------- -------------------------------------------------- ------------- Struct Tshortcutcfg {// Constructor Tshortcutcfg () {nshowcfg () {nshowcmd = sw_shownormal; who = 0; niconIndex = 0;} // Structural member: Ansistring strlnkdir; // Ansistring strlnkdir; // Ansistring strlnkdir; // AnsiString strDestFile; // AnsiString strArguments; // AnsiString strIconFile; // int nIconIndex; // AnsiString strWorkingDir; // AnsiString strDescription; // WORD wHotKey; // int nShowCmd; //}; // ---- -------------------------------------------------- --------------------- // Creating shortcuts Bool CreatequickLaunchShortcut (tshortcfg * scconfig) {char szbuf [max_path]; BOOL BRETURN = true; wchar_t WSZBUF [MAX_PATH]; ishelllink * pshelllink; Ansistring strshortcutfile; lpitemidlist lpitemidlist; shgetspec ialFolderLocation (0, CSIDL_APPDATA, & lpItemIdList); SHGetPathFromIDList (lpItemIdList, szBuf); if (DirectoryExists (AnsiString (szBuf))) {strShortcutFile = AnsiString (szBuf) "// Microsoft // Internet Explorer // Quick Launch //" scConfig-> strShortcutName ".lnk"; strShortcutFile.WideChar (wszBuf, MAX_PATH);} else bReturn = false; if (bReturn) {bReturn = CoCreateInstance (CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **) & pShellLink)> = 0; if (Breturn) {ipersistfile * ppf; Breturn = pshelllink->

QueryInterface (IID_IPERSISTFILE, (Void **) & PPF)> = 0; if (Breturn) {// Target file IF (scconfig-> strDestFile! = Emptystr) Breturn = pshelllink-> setPath (Scconfig-> strDestFile.c_str ()) > = 0; // Parameter IF (Breturn && Scconfig-> Strarguments! = EMPTYSTR) Breturn = pshelllink-> setarguments (scconfig-> stratageguments.c_str ())> = 0; // Display Icon IF (Breturn && Scconfig-> ! strIconFile = EmptyStr && FileExists (scConfig-> strIconFile)) pShellLink-> SetIconLocation (scConfig-> strIconFile.c_str (), scConfig-> nIconIndex);! // start position if (bReturn && scConfig-> strWorkingDir = EmptyStr) Pshelllink-> setWorkingDirectory (scconfig-> strworkingdir.c_str ()); // Remarks if (Breturn && Scconfig-> strDescription! = Emptystr) pshelllink-> setDescription (Scconfig-> strDesCr iption.c_str ()); // Shortcut key if (Breturn && Scconfig-> WhotKey! = 0) pshelllink-> sethotkey (Scconfig-> WhotKey); // Operation method if (Breturn && Scconfig-> nshowcmd! = 0) Pshelllink-> setshowcmd (scconfig-> nshowcmd); if (Breturn) Breturn = (PPF-> Save (WSZBUF, TRUE)> = 0); PPF-> Release ();} pshelllink-> release ();}} return Breturn;} // Call code:

转载请注明原文地址:https://www.9cbs.com/read-19646.html

New Post(0)