O
O
ozzzi2014-04-24 19:57:33
C++ / C#
ozzzi, 2014-04-24 19:57:33

How to add a shortcut launch parameter through the program?

Hello!
Let's say there is a shortcut (*.lnk):
[object: "C:\Games\Counter-Strike\hl.exe"]
Run the program, find this file (*.lnk) and change:
[object: "C:\Games \Counter-Strike\hl.exe" - game cstike ]
In general, tell me the code in C ++.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2014-04-24
@ozzzi

Something like this on bare COM:

IPersistFile *ipf;
  IShellLinkA *isl;
  HRESULT rc;

  rc=CoInitialize(NULL);
  rc=CoCreateInstance(CLSID_ShellLink,0,CLSCTX_INPROC_SERVER,IID_IPersistFile,(void**)&ipf);
  rc=ipf->Load(L"something.lnk",0);
  rc=ipf->QueryInterface(IID_IShellLinkA,(void**)&isl);
  rc=isl->SetArguments("- game cstike");
  rc=ipf->Save(L"something.lnk",1);
  ipf->Release();
  isl->Release();
  CoUninitialize();

For details of the IShellLink interface see msdn.microsoft.com/en-us/library/windows/desktop/b...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question