请问怎样在Windows桌面建立文件的快捷方式?要指定快捷方式的名字和设置窗口的运行方式(50分)

  • 主题发起人 主题发起人 Iveny
  • 开始时间 开始时间
I

Iveny

Unregistered / Unconfirmed
GUEST, unregistred user!
最好有简单点的方法和例子,详细介绍一下,谢了~<br>随便问问:怎么刷新桌面?(Windows API)<br><br><br>
 
创建Shortcut是使用IShellLink接口完成的,下面的代码展示了简单的创建过程<br>/*********************************<br>HRESULT hres;<br>IShellLink *psl;<br><br>// Create an IShellLink object and get a pointer to the IShellLink <br>// interface (returned from CoCreateInstance).<br>hres = CoCreateInstance (CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&amp;psl);<br>if (SUCCEEDED (hres)) {<br> IPersistFile *ppf;<br><br> // Query IShellLink for the IPersistFile interface for <br> // saving the shortcut in persistent storage.<br> hres = psl-&gt;QueryInterface (IID_IPersistFile, (void**)&amp;ppf);<br> if (SUCCEEDED (hres)) {<br> WORD wsz [MAX_PATH]; // buffer for Unicode string<br> <br> // Set the path to the shortcut target.<br> hres = psl-&gt;SetPath (pszShortcutFile);<br> if (! SUCCEEDED (hres))<br> AfxMessageBox ("SetPath failed!");<br><br> // Set the description of the shortcut.<br> hres = psl-&gt;SetDescription (pszDesc);<br> if (! SUCCEEDED (hres))<br> AfxMessageBox ("SetDescription failed!");<br><br> // Ensure that the string consists of ANSI characters.<br> MultiByteToWideChar (CP_ACP, 0, pszLink, -1, wsz, MAX_PATH);<br> <br> // Save the shortcut via the IPersistFile::Save member function.<br> hres = ppf-&gt;Save (wsz, TRUE);<br> <br> if (! SUCCEEDED (hres))<br> AfxMessageBox (“Save failed!”);<br> <br> // Release the pointer to IPersistFile.<br> ppf-&gt;Release ();<br> }<br> <br> // Release the pointer to IShellLink.<br> psl-&gt;Release ();<br>}<br>*****************************/<br>IShellLink 支持下列方法:<br><br>GetArguments &nbsp; &nbsp; &nbsp; &nbsp;Retrieves the command-line arguments associated with a shell link object. <br>GetDescription &nbsp; &nbsp; &nbsp;Retrieves the description string for a shell link object. <br>GetHotkey &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Retrieves the hot key for a shell link object. <br>GetIconLocation &nbsp; &nbsp; Retrieves the location (path and index) of the icon for a shell link object. <br>GetIDList &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Retrieves the list of item identifiers for a shell link object. <br>GetPath &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Retrieves the path and file name of a shell link object. <br>GetShowCmd &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Retrieves the show (SW_) command for a shell link object. <br>GetWorkingDirectory Retrieves the name of the working directory for a shell link object. <br>Resolve &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Resolves a shell link by searching for the shell link object and updating the shell link path and its list of identifiers (if necessary). <br>SetArguments &nbsp; &nbsp; &nbsp; &nbsp;Sets the command-line arguments associated with a shell link object. <br>SetDescription &nbsp; &nbsp; &nbsp;Sets the description string for a shell link object. <br>SetHotkey &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sets the hot key for a shell link object. <br>SetIconLocation &nbsp; &nbsp; Sets the location (path and index) of the icon for a shell link object. <br>SetIDList &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sets the list of item identifiers for a shell link object. <br>SetPath &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sets the path and file name of a shell link object. <br>SetRelativePath &nbsp; &nbsp; Sets the relative path for a shell link object. <br>SetShowCmd &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Sets the show (SW_) command for a shell link object. <br>SetWorkingDirectory Sets the name of the working directory for a shell link object. <br>细节可参考MSDN。
 
你的例子我不太懂呢?!<br>可以举简单点的例子吗?!或者请麻烦你用中文说明语句的含意,谢谢:)<br>我很需要IShellLink的方法的详细用法,但我找不到,请问能否告知(中文)?<br>这个快捷方式是Dos的,我需要设置它退出时关闭,请问用那个函数?参数是?<br>先谢谢了^_^
 
接受答案了.
 
后退
顶部