如何编程实现更改快捷方式文件(*.lnk)中的内容,比如改变他所指向的文件名称和路径,我出50大元.(100分)

  • 主题发起人 主题发起人 actionboy
  • 开始时间 开始时间
.lnk文件就是ini格式,你在dos prompt下,cat 一下lnk文件就知道了。<br>用tinifile打开.lnk文件,怎么修改应该不用说了吧。
 
cat,tinifile都是什么东西阿?<br>高手指教!
 
void __fastcall TFMain::CreateDesktopShortCut(const AnsiString sMyFileName,const AnsiString ShortCutName)<br>{<br>&nbsp; char sShortCutLink[1024];<br>&nbsp; AnsiString sFileName;<br>&nbsp; char szBuffer[1024];<br>&nbsp; char szShortCutDesc[80];<br>&nbsp; char *pPos;<br>&nbsp; GetSystemDirectory(szBuffer, 1023);<br>&nbsp; &nbsp; strupr(szBuffer);<br>&nbsp; &nbsp; pPos = strstr(szBuffer, "SYSTEM");<br>&nbsp; &nbsp; if (pPos != NULL)<br>&nbsp; &nbsp; &nbsp; *pPos = '/0';<br><br>&nbsp; strcat(szBuffer, "Desktop");<br>&nbsp; sFileName="//"+ShortCutName;<br><br>&nbsp; //pPos = strrchr(sFileName.c_str(), '//');<br>&nbsp; //if (pPos != NULL)<br>&nbsp; &nbsp; //StrPCopy(sFileName.c_str(), pPos);<br>&nbsp; // &nbsp;sFileName=pPos;<br>&nbsp; strcpy(szShortCutDesc, "&amp;Iacute;&amp;otilde;&amp;Oacute;&amp;brvbar;&amp;Auml;&amp;Iuml;±à&amp;ETH;&amp;acute;");<br>&nbsp; strcat(szBuffer, "//");<br>&nbsp; strcpy(sShortCutLink, szBuffer);<br>&nbsp; strcat(sShortCutLink, sFileName.c_str());<br><br>&nbsp; //pPos = strchr(sShortCutLink, '.');<br>&nbsp; //if (pPos != NULL)<br>&nbsp; // &nbsp;*pPos = '/0';<br>&nbsp; strcat(sShortCutLink, ".LNK");<br>&nbsp; CreateShortCut(sMyFileName.c_str(), sShortCutLink, szShortCutDesc);<br>}<br>void __fastcall TFMain::CreateShortCut(char *pFileName, char *pLink, char*pDesc)<br>{<br>&nbsp; IShellLink *psl;<br>&nbsp; IPersistFile *ppf;<br>&nbsp; wchar_t szWChar[1024];<br><br>&nbsp; try<br>&nbsp; {<br>&nbsp; &nbsp; OleCheck(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IID_IShellLink, (void **) &amp;psl) );<br>&nbsp; &nbsp; try<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; OleCheck(psl-&gt;QueryInterface(IID_IPersistFile, (void **) &amp;ppf) );<br>&nbsp; &nbsp; &nbsp; OleCheck(psl-&gt;SetDescription(pDesc));<br>&nbsp; &nbsp; &nbsp; OleCheck(psl-&gt;SetPath(pFileName));<br>&nbsp; &nbsp; &nbsp; MultiByteToWideChar(CP_ACP, 0, pLink, -1, szWChar, 1023);<br>&nbsp; &nbsp; &nbsp; OleCheck(ppf-&gt;Save(szWChar, TRUE));<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; catch (...)<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; ppf-&gt;Release();<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; ppf-&gt;Release();<br>&nbsp; }<br>&nbsp; catch(...)<br>&nbsp; {<br>&nbsp; &nbsp; psl-&gt;Release();<br>&nbsp; }<br>&nbsp; psl-&gt;Release();<br>}<br><br><br><br><br><br><br>&nbsp; &nbsp; &nbsp; &nbsp; CreateDesktopShortCut(Application-&gt;ExeName,"test");<br>&nbsp; &nbsp; &nbsp; &nbsp; CreateDesktopShortCut(ExtractFilePath(Application-&gt;ExeName)+"MainDelprj.exe","test");<br>
 
请大家少等。我试试后给大家分.<br>
 
来迟了<br>这个问题以前就有人问过了
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部