makelink.pas 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. program MakeLink;
  2. uses
  3. Strings,
  4. Windows,
  5. WinShell;
  6. procedure ReadFailure;
  7. begin
  8. Writeln('Reading of config file failed');
  9. Halt(1);
  10. end;
  11. var
  12. DesktopPath : PChar;
  13. Line,
  14. Typ : String;
  15. ExeName,
  16. LinkName,
  17. IconName,
  18. Comment,
  19. WorkingDir : Array [0..MAX_PATH] of char;
  20. f : text;
  21. begin
  22. DesktopPath := StrAlloc (MAX_PATH);
  23. { How could we know if the installer as access to global
  24. desktop dir ?? }
  25. GetDesktopFolder (true, DesktopPath);
  26. if (ParamCount=2) and (ParamStr(1)='-F') then
  27. begin
  28. Assign(f,ParamStr(2));
  29. Reset(f);
  30. if IOResult<>0 then
  31. ReadFailure;
  32. while not eof(f) do
  33. begin
  34. readln(f,line);
  35. typ:=copy(line,1,pos('=',line)-1);
  36. line:=copy(line,pos('=',line)+1,high(line));
  37. if typ='ExePath' then
  38. StrPCopy(ExeName,Line);
  39. if typ='LinkName' then
  40. StrPCopy(LinkName,Line);
  41. if typ='IconPath' then
  42. StrPCopy(IconName,Line);
  43. if typ='Comment' then
  44. StrPCopy(Comment,Line);
  45. if typ='WorkingDir' then
  46. StrPCopy(WorkingDir,Line);
  47. end;
  48. end;
  49. StrCat (DesktopPath, '\');
  50. StrCat (DesktopPath,LinkName);
  51. CreateShortcut (DesktopPath,
  52. ExeName,
  53. nil,
  54. WorkingDir,
  55. Comment,
  56. IconName,
  57. 0);
  58. StrDispose (DesktopPath);
  59. end.