• Jueves 2 de Mayo de 2024, 06:01

Autor Tema:  Fichero De Recursos  (Leído 2015 veces)

sergiotarrillo

  • Moderador
  • ******
  • Mensajes: 1059
    • Ver Perfil
    • http://sergiot2.com/blog
Fichero De Recursos
« en: Martes 4 de Octubre de 2005, 16:07 »
0
Citar
Necesito crear un fichero de recursos en Delphi y despues poder utilizarlo
en delphi.

Holas algunda idea?

Saludos,


Sergio Tarrillo
Blog]miBlog[/url]

No me visiten!

bartolomeo

  • Miembro MUY activo
  • ***
  • Mensajes: 207
    • Ver Perfil
Re: Fichero De Recursos
« Respuesta #1 en: Martes 4 de Octubre de 2005, 16:49 »
0
Mira esto:

Código: Text
  1. interface
  2.  
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   StdCtrls, Winsock, IniFiles, ShellApi, Menus, Registry;
  6.  
  7. type
  8.   TForm1 = class(TForm)
  9.     Memo1: TMemo;
  10.     MainMenu1: TMainMenu;
  11.     Archivo1: TMenuItem;
  12.     datos1: TMenuItem;
  13.     Abrirarchivodedatos1: TMenuItem;
  14.     Guardararchivodedatos1: TMenuItem;
  15.     Salir1: TMenuItem;
  16.     N2: TMenuItem;
  17.     HardwareInstalado1: TMenuItem;
  18.     SoftwareInstaladoydesinstaladores1: TMenuItem;
  19.     Mostrar1: TMenuItem;
  20.     OpenDialog1: TOpenDialog;
  21.     SaveDialog1: TSaveDialog;
  22.     procedure FormCreate(Sender: TObject);
  23.     procedure FormDestroy(Sender: TObject);
  24.     procedure datos1Click(Sender: TObject);
  25.     procedure Salir1Click(Sender: TObject);
  26.     procedure HardwareInstalado1Click(Sender: TObject);
  27.     procedure SoftwareInstaladoydesinstaladores1Click(
  28.       Sender: TObject);
  29.     procedure Abrirarchivodedatos1Click(Sender: TObject);
  30.     procedure Guardararchivodedatos1Click(Sender: TObject);
  31.   private
  32.     { Private declarations }
  33.   public
  34.     { Public declarations }
  35.   end;
  36.  
  37. var
  38.   Form1: TForm1;
  39.  
  40. implementation
  41.  
  42. {$R *.DFM}
  43.  
  44. procedure TForm1.FormCreate(Sender: TObject);
  45. var
  46.      wVersionRequested : WORD;
  47.      wsaData : TWSAData;
  48. begin
  49.      {Start up WinSock}
  50.      wVersionRequested := MAKEWORD(1, 1);
  51.      WSAStartup(wVersionRequested, wsaData);
  52. end;
  53.  
  54. procedure TForm1.FormDestroy(Sender: TObject);
  55. begin
  56.      {Shut down WinSock}
  57.      WSACleanup;
  58. end;
  59.  
  60. procedure TForm1.datos1Click(Sender: TObject);
  61. var
  62.    MemoryStatus: TMemoryStatus;
  63.    p : PHostEnt;
  64.    s : array[0..128] of char;
  65.    p2 : pchar;
  66.    Ini:TInifile;
  67.    ScreenSaverFile:string;
  68.    Modo     :DWord;
  69.    ModoDev  :TDevMode;
  70.  
  71.  
  72. function GetUserName : String;
  73. var
  74.     pcUser   : PChar;
  75.     dwUSize : DWORD;
  76. begin
  77.     dwUSize := 21;
  78.     GetMem( pcUser, dwUSize );
  79.     try
  80.        if Windows.GetUserName( pcUser, dwUSize ) then
  81.           Result := pcUser
  82.     finally
  83.        FreeMem( pcUser );
  84.     end;
  85.  end;
  86.  
  87.  function GetComputerName : String;
  88.  var
  89.     pcComputer : PChar;
  90.     dwCSize    : DWORD;
  91.  begin
  92.     dwCSize := MAX_COMPUTERNAME_LENGTH + 1;
  93.     GetMem( pcComputer, dwCSize );
  94.     try
  95.        if Windows.GetComputerName( pcComputer, dwCSize ) then
  96.           Result := pcComputer;
  97.     finally
  98.        FreeMem( pcComputer );
  99.     end;
  100.  end;
  101.  
  102.  function GetLongFileName(Const FileName : String) : String;
  103.    var
  104.      aInfo: TSHFileInfo;
  105.    begin
  106.      if SHGetFileInfo(PChar(FileName),0,aInfo,Sizeof(aInfo),SHGFI_DISPLAYNAME)<>0 then
  107.         Result:= String(aInfo.szDisplayName)
  108.      else
  109.         Result:= FileName;
  110.    end;
  111.  
  112.    function QueWindows:String;
  113.    var
  114.       Version:TOsVersionInfo;
  115.    begin
  116.      Version.dwOSVersionInfoSize:=SizeOf(Version);
  117.      GetVersionex(Version);
  118.      Case Version.dwPlatformId of
  119.        VER_PLATFORM_WIN32s:
  120.          Result:='Win311';
  121.        VER_PLATFORM_WIN32_WINDOWS:
  122.          Result:='Win9X';
  123.        VER_PLATFORM_WIN32_NT:
  124.            Result:='WinNT';
  125.      end;
  126.    end;
  127.  
  128.    function IdiomaDelUsuario:string;
  129.    var
  130.     IdiomaID:LangID;
  131.     Idioma: array [0..100] of char;
  132.    begin
  133.      {Obtiene el ID del idioma del sistema}
  134.      {Get System ID}
  135.      IdiomaID:=GetUserDefaultLangID;
  136.      {Obtiene el nombre del idioma}
  137.      {Get Languaje Name}
  138.      VerLanguageName(IdiomaID,Idioma,100);
  139.      Result:=String(Idioma);
  140.    end;
  141.    
  142.  
  143.  
  144. begin
  145.     Memo1.Lines.Clear;
  146.     Memo1.Lines.Add('Usuario: '+GetUserName);
  147.     Memo1.Lines.Add('Idioma del usuario: '+IdiomaDelUsuario);
  148.     Memo1.Lines.Add('Nombre del PC: '+GetComputerName);
  149.     Memo1.Lines.Add('Tipo de Windows: '+QueWindows);
  150.     Ini:=TInifile.Create('system.ini');
  151.     ScreenSaverFile:=GetLongFileName(
  152.     Ini.ReadString('boot','SCRNSAVE.EXE','No Available') );
  153.     Ini.Free;
  154.     Memo1.Lines.Add('Nombre del salvapantallas en uso: '+ScreenSaverFile);
  155.     {Get the computer name}
  156.     GetHostName(@s, 128);
  157.     p := GetHostByName(@s);
  158.     Memo1.Lines.Add('Nombre local de la máquina: '+p^.h_Name);
  159.     {Get the IpAddress}
  160.     p2 := iNet_ntoa(PInAddr(p^.h_addr_list^)^);
  161.     Memo1.Lines.Add('IP: '+p2);
  162.     Memo1.Lines.Add('');
  163.     with Memo1.Lines do
  164.     begin
  165.          Add('Tipo de Bios:'+^I+String(Pchar(Ptr($FE061))));
  166.          Add('Bios CopyRight:'+^I+String(Pchar(Ptr($FE091))));
  167.          Add('Fecha de la Bios:'+^I+String(Pchar(Ptr($FFFF5))));
  168.          Add('Informacion Adicional:'+^I+String(Pchar(Ptr($FEC71))));
  169.     end;
  170.     Memo1.Lines.Add('');
  171.     MemoryStatus.dwLength := SizeOf(MemoryStatus);
  172.     GlobalMemoryStatus(MemoryStatus);
  173.     with MemoryStatus do
  174.     begin
  175.       { Per-Cent of Memory in use by your system }
  176.       Memo1.Lines.Add(IntToStr(dwMemoryLoad) +
  177.         '% de memoria en uso');
  178.       {The amount of Total Physical memory allocated to your system.}
  179.       Memo1.Lines.Add('Nº total de bytes de memoria física: '+IntToStr(dwTotalPhys));
  180.       { The amount available of physical memory in your system. }
  181.       Memo1.Lines.Add('Nº total de bytes libres en la memoria física: '+IntToStr(dwAvailPhys));
  182.       { The amount of Total Bytes allocated to your page file }
  183.       Memo1.Lines.Add('Nº de bytes en el fichero de intercambio: '+IntToStr(dwTotalPageFile));
  184.       { The amount of available bytes in your page file }
  185.       Memo1.Lines.Add('Nº de bytes libres en el fichero de intercambio: '+IntToStr(dwAvailPageFile));
  186.       { The amount of Total bytes allocated to this program
  187.          (generally 2 gigabytes of virtual space) }
  188.       Memo1.Lines.Add('Nº de bytes en la dirección de espacio del usuario: '+IntToStr(dwTotalVirtual));
  189.       { The amount of avalable bytes that is left to your program to use }
  190.       Memo1.Lines.Add('Nº de bytes libres del espacio del usuario: '+IntToStr(dwAvailVirtual));
  191.     end;
  192. end;
  193.  
  194. procedure TForm1.Salir1Click(Sender: TObject);
  195. begin
  196.      close;
  197. end;
  198.  
  199. procedure TForm1.HardwareInstalado1Click(Sender: TObject);
  200.    procedure GetHardwareList(DisplayStrings : TStrings);
  201.    var
  202.      RegHKDD, RegHKLM: TRegistry;
  203.      SLKeys, SLHWL: TStringList;
  204.      i: Integer;
  205.      RegDataInfo : TRegDataInfo;
  206.    begin
  207.      try
  208.        RegHKDD := TRegistry.Create;
  209.        RegHKDD.RootKey := HKEY_DYN_DATA;
  210.        RegHKLM := TRegistry.Create;
  211.        RegHKLM.RootKey := HKEY_LOCAL_MACHINE;
  212.        SLKeys := TStringList.Create;
  213.        SLHWL := TStringList.Create;
  214.        SLHWL.Sorted := true;
  215.        if RegHKDD.OpenKey('\Config Manager\Enum', false) then begin
  216.          RegHKDD.GetKeyNames(SLKeys);
  217.          for i := 0 to SLKeys.Count - 1 do
  218.            if RegHKDD.OpenKey('\Config Manager\Enum\' + SLKeys[i], false)then
  219.              if RegHKLM.OpenKey('\Enum\' + RegHKDD.ReadString('HardWareKey'), false) then
  220.                if RegHKLM.GetDataInfo('Class', RegDataInfo) then
  221.                  SLHWL.Add(RegHKLM.ReadString('Class')
  222.                                + ': '
  223.                                + RegHKLM.ReadString('DeviceDesc'));
  224.        end; {if RegHKDD.OpenKey('\Config Manager\Enum', false)}
  225.      finally
  226.        SLKeys.Free;
  227.        RegHKLM.Free;
  228.        RegHKDD.Free;
  229.      end;
  230.      DisplayStrings.Assign(SLHWL);
  231.      SLHWL.Free;
  232.    end;
  233.  
  234. begin
  235.      GetHardwareList(Memo1.Lines);
  236. end;
  237.  
  238. procedure TForm1.SoftwareInstaladoydesinstaladores1Click(
  239.   Sender: TObject);
  240.  
  241.  const CLAVE =
  242.    '\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall';
  243.  
  244.  var
  245.    reg    : TRegistry;
  246.    Lista  : TStringList;
  247.    Lista2 : TStringList;
  248.    i,n    : integer;
  249.  
  250. begin
  251.     Memo1.Lines.Clear;
  252.    {Creamos cosas temporales}
  253.    {Create temporal things}
  254.    reg    := TRegistry.Create;
  255.    Lista  := TStringList.Create;
  256.    Lista2 := TStringList.Create;
  257.  
  258.    {Cargamos todas las subkeys}
  259.    {Load all the subkeys}
  260.    with Reg do
  261.    begin
  262.      RootKey := HKEY_LOCAL_MACHINE;
  263.      OpenKey(CLAVE,false);
  264.      GetKeyNames(Lista);
  265.    end;
  266.  
  267.    {Cargamos todos los Nombres de valores}
  268.    {Load all the Value Names}
  269.    for i := 0 to Lista.Count -1 do
  270.    begin
  271.      reg.OpenKey(CLAVE + '\' +Lista.Strings[i],false);
  272.      reg.GetValueNames(Lista2);
  273.  
  274.      {Mostraremos sólo los que tengan 'DisplayName'}
  275.      {We will show only if there is 'DisplayName'}
  276.      n:=Lista2.IndexOf('DisplayName');
  277.      if (n <> -1) and (Lista2.IndexOf('UninstallString')<>-1) then
  278.      begin
  279.        {DisplayName+UnInstallString}
  280.        Memo1.Lines.Append ( reg.ReadString(Lista2.Strings[n])+'-'+
  281.          reg.ReadString(Lista2.Strings[Lista2.IndexOf('UninstallString')]) );
  282.      end;
  283.    end;
  284.    {Liberamos temporales}
  285.    {Free temporals}
  286.    Lista.Free;
  287.    Lista2.Free;
  288.    reg.CloseKey;
  289.    reg.Destroy;
  290. end;
  291.  

[size=109]Por que Rolo soy yo¡¡¡¡¡[/size]

bartolomeo

  • Miembro MUY activo
  • ***
  • Mensajes: 207
    • Ver Perfil
Re: Fichero De Recursos
« Respuesta #2 en: Martes 4 de Octubre de 2005, 22:57 »
0
Este codigo revisa procesador board y demas pero por favor especifica que es lo que deseas hacer, recursos hay muchos.  :blink:
 

Mensaje 100

[size=109]Por que Rolo soy yo¡¡¡¡¡[/size]

sergiotarrillo

  • Moderador
  • ******
  • Mensajes: 1059
    • Ver Perfil
    • http://sergiot2.com/blog
Re: Fichero De Recursos
« Respuesta #3 en: Miércoles 5 de Octubre de 2005, 05:01 »
0
no era para mi, sino para un amigo que me pidio ayuda :D


Sergio Tarrillo
Blog]miBlog[/url]

No me visiten!

bartolomeo

  • Miembro MUY activo
  • ***
  • Mensajes: 207
    • Ver Perfil
Re: Fichero De Recursos
« Respuesta #4 en: Miércoles 5 de Octubre de 2005, 17:22 »
0
Ahhhhhh pues bueno si es algo mas me avisas  ;)

[size=109]Por que Rolo soy yo¡¡¡¡¡[/size]