Ir al contenido


Foto

[TRUCO DELPHI] Poner tu programa en el menu de Inicio y en el Escritorio.


  • Por favor identifícate para responder
1 respuesta en este tema

#1 sir.dev.a.lot

sir.dev.a.lot

    Advanced Member

  • Miembros
  • PipPipPip
  • 545 mensajes
  • Location127.0.0.1

Escrito 10 diciembre 2016 - 05:22

[TRUCO DELPHI] Poner tu programa en el menu de Inicio y en el Escritorio.


delphi
  1. procedure TForm1.AddToStartMenu;
  2. var
  3. MyObject : IUnknown;
  4. MySLink : IShellLink;
  5. MyPFile : IPersistFile;
  6. Directory : String;
  7. WFileName : WideString;
  8. MyReg : TRegIniFile;
  9. begin
  10. MyObject := CreateComObject(CLSID_ShellLink);
  11. MySLink := MyObject as IShellLink;
  12. MyPFile := MyObject as IPersistFile;
  13.  
  14. with MySLink do begin
  15. SetArguments(PChar(application.exename));
  16. SetRelativePath(PChar(ExtractFilePath(application.exename)),0);
  17. SetHotKey(635); //Define el Acceso Directo - Ctl-F12
  18.  
  19. SetWorkingDirectory(PChar(ExtractFilePath(application.exename)));
  20. SetDescription(PChar('Tu Desripcion'));
  21. SetIconLocation(PChar(application.exename),0); //Icono del menu de Inicio.
  22. end;
  23. MyReg := TRegIniFile.Create(
  24. 'Software\MicroSoft\Windows\CurrentVersion\Explorer');
  25.  
  26. // Programa en el Escritorio
  27. Directory := MyReg.ReadString('Shell Folders','Desktop','');
  28.  
  29. // Programa en el Menu de Inicio
  30. Directory := MyReg.ReadString('Shell Folders','Start Menu','')+
  31. '\Programs\YourProgram';
  32. CreateDir(Directory);
  33.  
  34. WFileName := Directory+'\Mi Sistema.lnk';
  35. MyPFile.Save(PWChar(WFileName),False);
  36. MyReg.Free;
  37.  
  38. end;

Saludos!


  • 1

#2 escafandra

escafandra

    Advanced Member

  • Administrador
  • 4.107 mensajes
  • LocationMadrid - España

Escrito 11 diciembre 2016 - 10:46

¿Y las interfaces de Windows?

 

Saludos.


  • 0




IP.Board spam blocked by CleanTalk.