本文整理自网络,侵删。
delphi 修改快捷方式
function CrnModifyShortcutArguments(strLnkFile:String;strArguments:String):boolean;
var
wszBuf:array [0..MAX_PATH] of widechar;
szBuf :array [0..MAX_PATH] of char;
bResult: boolean;
pShellLink:^IShellLink;
ppf :^IPersistFile;
begin
if not FileExists(strLnkFile) then
begin
MessageBox(0, '指定的快捷方式未找到!', '错误', MB_OK or MB_ICONERROR);
result:= False;
end;
//WideChar(wszBuf,MAX_PATH);
bResult:= (CoInitialize(nil)=S_OK);
//@1
if (bResult) then
begin
bResult:= Boolean(CoCreateInstance(CLSID_ShellLink,nil,CLSCTX_INPROC_SERVER,IShellLink,pointer(pShellLink)) >= 0);
//*@2
if(bResult) then
begin
bResult:= pshellLink^.QueryInterface(IShellLink,pointer(PPF))>= 0;
//*@3
if (bResult) then
begin
bResult:= ppf^.Load(wszBuf, 0) >= 0;
//*@4
if (bResult) then
begin
pShellLink^.SetArguments(pchar(strArguments));
bResult:= ppf^.Save(wszBuf, TRUE) >= 0;
end;
ppf^._Release();
end;
pShellLink^._Release();
end;
CoUninitialize();
end;
result:= bResult;
end;
相关阅读 >>
Delphi 10 seattle的android应用程序的主屏幕上创建快捷方式
Delphi windows 编程[11] - wm_size 消息
Delphi dbexpress的upwherekeyonly的使用注意事项
Delphi unigui中如何监听session的开始与结束
Delphi Delphi中点击dbgrid某一行获得其详细数据方法
更多相关阅读请进入《Delphi》频道 >>