Re: [delphi-br] Nome do autor de um arquivo

2010-05-27 Por tôpico Murilo Cunha
Edelson,

Tente o seguinte:

~
{
Usage:
VersionInformation(ListBox1)
}

{Pads or truncates a String and
Justifies Left if StrJustify=True}
Function StringPad(
InputStr,
FillChar: String;
StrLen: Integer;
StrJustify: Boolean): String;
Var
TempFill: String;
Counter : Integer;
Begin
If Not (Length(InputStr) = StrLen) Then
Begin
  If Length(InputStr)  StrLen Then
  Begin
InputStr := Copy(InputStr,1,StrLen) ;
  End
  Else
  Begin
TempFill := '';
For Counter := 1 To StrLen-Length(InputStr) Do
Begin
  TempFill := TempFill + FillChar;
End;
If StrJustify Then
Begin
  {Left Justified}
  InputStr := InputStr + TempFill;
End
Else
Begin
  {Right Justified}
  InputStr := TempFill + InputStr ;
End;
  End;
End;
Result := InputStr;
End;


Function VersionInformation(
ListBox : TListBox): Boolean;
const
InfoNum = 11;
InfoStr : array [1..InfoNum] of String =
  ('CompanyName', 'FileDescription', 'FileVersion',
'InternalName', 'LegalCopyright', 'LegalTradeMarks',
'OriginalFilename', 'ProductName', 'ProductVersion',
'Comments', 'Author') ;
LabelStr : array [1..InfoNum] of String =
  ('Company Name', 'Description', 'File Version',
'Internal Name', 'Copyright', 'TradeMarks',
'Original File Name', 'Product Name',
'Product Version', 'Comments', 'Author') ;
var
S : String;
n, Len, j : Integer;
Buf : PChar;
Value : PChar;
begin
Try
  S := Application.ExeName;
  ListBox.Items.Clear;
  ListBox.Sorted := True;
  ListBox.Font.Name := 'Courier New';
  n := GetFileVersionInfoSize(PChar(S),n) ;
  If n  0 Then Begin
Buf := AllocMem(n) ;
ListBox.Items.Add
(StringPad('Size',' ',20,True)+' = '+IntToStr(n)) ;
GetFileVersionInfo(PChar(S),0,n,Buf) ;
For j:=1 To InfoNum Do Begin
  If VerQueryValue(Buf,PChar('StringFileInfo\040904E4\'+
InfoStr[j]),Pointer(Value),Len) Then
  Begin
Value := PChar(Trim(Value)) ;
If Length(Value)  0 Then
Begin
  ListBox.Items.Add
(StringPad(labelStr,' ',20,True)+' = '+Value) ;
End;
  End;
End;
FreeMem(Buf,n) ;
  End
  Else Begin
ListBox.Items.Add
('No FileVersionInfo found') ;
  End;
  Result := True;
Except
  Result := False;
End;
End;
~


Obrigado.
MuriloCunha





On 26/05/2010 14:43, Edelson Regis de Lima wrote:
 Boa tarde pessoal!

 Já dei uma pesquisada nas mensagens antigas do forum, mas não encontrei...
 Alguém sabe se dá para criar um arquivo, e no momento da sua criação
 informar o nome do Autor? (Aquela propriedade que o windows mostra quando
 vemos as propriedades do arquivo)
 E também como extrair de um arquivo o nome do Autor.

 A data e hora de criação eu já consegui extrair da seguinte maneira:
 FileDateToDateTime(FileAge('Nome_Do_Arquivo'))

 Mas preciso extrair também o nome do Autor.

 Obrigado!

 Edelson.


 [As partes desta mensagem que não continham texto foram removidas]



 





Re: [delphi-br] Nome do autor de um arquivo

2010-05-27 Por tôpico Adriano Santos
Edelson,

Funcionou a dica do Murilo? Muito legal hein Murilo?

Adriano Santos
Vendo Sony Vaio http://bit.ly/aWrKyW
http://twitter.com/asrsantos
http://delphitodelphi.blogspot.com

Em Thu, May 27, 2010 at 8:10 AM, Murilo Cunha mcscu...@yahoo.com.brescreveu:



 Edelson,

 Tente o seguinte:

 ~
 {
 Usage:
 VersionInformation(ListBox1)
 }

 {Pads or truncates a String and
 Justifies Left if StrJustify=True}
 Function StringPad(
 InputStr,
 FillChar: String;
 StrLen: Integer;
 StrJustify: Boolean): String;
 Var
 TempFill: String;
 Counter : Integer;
 Begin
 If Not (Length(InputStr) = StrLen) Then
 Begin
 If Length(InputStr)  StrLen Then
 Begin
 InputStr := Copy(InputStr,1,StrLen) ;
 End
 Else
 Begin
 TempFill := '';
 For Counter := 1 To StrLen-Length(InputStr) Do
 Begin
 TempFill := TempFill + FillChar;
 End;
 If StrJustify Then
 Begin
 {Left Justified}
 InputStr := InputStr + TempFill;
 End
 Else
 Begin
 {Right Justified}
 InputStr := TempFill + InputStr ;
 End;
 End;
 End;
 Result := InputStr;
 End;

 Function VersionInformation(
 ListBox : TListBox): Boolean;
 const
 InfoNum = 11;
 InfoStr : array [1..InfoNum] of String =
 ('CompanyName', 'FileDescription', 'FileVersion',
 'InternalName', 'LegalCopyright', 'LegalTradeMarks',
 'OriginalFilename', 'ProductName', 'ProductVersion',
 'Comments', 'Author') ;
 LabelStr : array [1..InfoNum] of String =
 ('Company Name', 'Description', 'File Version',
 'Internal Name', 'Copyright', 'TradeMarks',
 'Original File Name', 'Product Name',
 'Product Version', 'Comments', 'Author') ;
 var
 S : String;
 n, Len, j : Integer;
 Buf : PChar;
 Value : PChar;
 begin
 Try
 S := Application.ExeName;
 ListBox.Items.Clear;
 ListBox.Sorted := True;
 ListBox.Font.Name := 'Courier New';
 n := GetFileVersionInfoSize(PChar(S),n) ;
 If n  0 Then Begin
 Buf := AllocMem(n) ;
 ListBox.Items.Add
 (StringPad('Size',' ',20,True)+' = '+IntToStr(n)) ;
 GetFileVersionInfo(PChar(S),0,n,Buf) ;
 For j:=1 To InfoNum Do Begin
 If VerQueryValue(Buf,PChar('StringFileInfo\040904E4\'+
 InfoStr[j]),Pointer(Value),Len) Then
 Begin
 Value := PChar(Trim(Value)) ;
 If Length(Value)  0 Then
 Begin
 ListBox.Items.Add
 (StringPad(labelStr,' ',20,True)+' = '+Value) ;
 End;
 End;
 End;
 FreeMem(Buf,n) ;
 End
 Else Begin
 ListBox.Items.Add
 ('No FileVersionInfo found') ;
 End;
 Result := True;
 Except
 Result := False;
 End;
 End;
 ~

 Obrigado.
 MuriloCunha


 On 26/05/2010 14:43, Edelson Regis de Lima wrote:
  Boa tarde pessoal!
 
  Já dei uma pesquisada nas mensagens antigas do forum, mas não
 encontrei...
  Alguém sabe se dá para criar um arquivo, e no momento da sua criação
  informar o nome do Autor? (Aquela propriedade que o windows mostra quando
  vemos as propriedades do arquivo)
  E também como extrair de um arquivo o nome do Autor.
 
  A data e hora de criação eu já consegui extrair da seguinte maneira:
  FileDateToDateTime(FileAge('Nome_Do_Arquivo'))
 
  Mas preciso extrair também o nome do Autor.
 
  Obrigado!
 
  Edelson.
 
 
  [As partes desta mensagem que não continham texto foram removidas]
 
 
 
  
 
 

  




-- 
Adriano Santos
http://twitter.com/asrsantos
www.delphitodelphi.blogspot.com


[As partes desta mensagem que não continham texto foram removidas]





-- 
 FAVOR REMOVER ESTA PARTE AO RESPONDER ESTA MENSAGEM 

* Para ver as mensagens antigas, acesse:
http://br.groups.yahoo.com/group/delphi-br/messages

* Para falar com o moderador, envie um e-mail para:
delphi-br-ow...@yahoogrupos.com.br
Links do Yahoo! Grupos

* Para visitar o site do seu grupo na web, acesse:
http://br.groups.yahoo.com/group/delphi-br/

* Para sair deste grupo, envie um e-mail para:
delphi-br-unsubscr...@yahoogrupos.com.br

* O uso que você faz do Yahoo! Grupos está sujeito aos:
http://br.yahoo.com/info/utos.html




Re: [delphi-br] Nome do autor de um arquivo

2010-05-27 Por tôpico Edelson Regis de Lima
Olá Pessoal!

Murilo, obrigado pela ajuda!

Respondendo à pergunta do Adriano, ainda não funcionou...
Não sei se esse código foi feito numa versão mais antiga do delphi (estou
usando Delphi 2007), mas só preenche o ListBox com o Size do aqruivo.
Vou tentar fazer algumas modificações na rotina, para ver se obtenho algum
resultado.

Abraços,

Edelson.



Em 27 de maio de 2010 10:06, Adriano Santos asrsan...@gmail.com escreveu:

 Edelson,

 Funcionou a dica do Murilo? Muito legal hein Murilo?

 Adriano Santos
 Vendo Sony Vaio http://bit.ly/aWrKyW
 http://twitter.com/asrsantos
 http://delphitodelphi.blogspot.com

 Em Thu, May 27, 2010 at 8:10 AM, Murilo Cunha mcscu...@yahoo.com.br
 escreveu:

 
 
  Edelson,
 
  Tente o seguinte:
 
  ~
  {
  Usage:
  VersionInformation(ListBox1)
  }
 
  {Pads or truncates a String and
  Justifies Left if StrJustify=True}
  Function StringPad(
  InputStr,
  FillChar: String;
  StrLen: Integer;
  StrJustify: Boolean): String;
  Var
  TempFill: String;
  Counter : Integer;
  Begin
  If Not (Length(InputStr) = StrLen) Then
  Begin
  If Length(InputStr)  StrLen Then
  Begin
  InputStr := Copy(InputStr,1,StrLen) ;
  End
  Else
  Begin
  TempFill := '';
  For Counter := 1 To StrLen-Length(InputStr) Do
  Begin
  TempFill := TempFill + FillChar;
  End;
  If StrJustify Then
  Begin
  {Left Justified}
  InputStr := InputStr + TempFill;
  End
  Else
  Begin
  {Right Justified}
  InputStr := TempFill + InputStr ;
  End;
  End;
  End;
  Result := InputStr;
  End;
 
  Function VersionInformation(
  ListBox : TListBox): Boolean;
  const
  InfoNum = 11;
  InfoStr : array [1..InfoNum] of String =
  ('CompanyName', 'FileDescription', 'FileVersion',
  'InternalName', 'LegalCopyright', 'LegalTradeMarks',
  'OriginalFilename', 'ProductName', 'ProductVersion',
  'Comments', 'Author') ;
  LabelStr : array [1..InfoNum] of String =
  ('Company Name', 'Description', 'File Version',
  'Internal Name', 'Copyright', 'TradeMarks',
  'Original File Name', 'Product Name',
  'Product Version', 'Comments', 'Author') ;
  var
  S : String;
  n, Len, j : Integer;
  Buf : PChar;
  Value : PChar;
  begin
  Try
  S := Application.ExeName;
  ListBox.Items.Clear;
  ListBox.Sorted := True;
  ListBox.Font.Name := 'Courier New';
  n := GetFileVersionInfoSize(PChar(S),n) ;
  If n  0 Then Begin
  Buf := AllocMem(n) ;
  ListBox.Items.Add
  (StringPad('Size',' ',20,True)+' = '+IntToStr(n)) ;
  GetFileVersionInfo(PChar(S),0,n,Buf) ;
  For j:=1 To InfoNum Do Begin
  If VerQueryValue(Buf,PChar('StringFileInfo\040904E4\'+
  InfoStr[j]),Pointer(Value),Len) Then
  Begin
  Value := PChar(Trim(Value)) ;
  If Length(Value)  0 Then
  Begin
  ListBox.Items.Add
  (StringPad(labelStr,' ',20,True)+' = '+Value) ;
  End;
  End;
  End;
  FreeMem(Buf,n) ;
  End
  Else Begin
  ListBox.Items.Add
  ('No FileVersionInfo found') ;
  End;
  Result := True;
  Except
  Result := False;
  End;
  End;
  ~
 
  Obrigado.
  MuriloCunha
 
 
  On 26/05/2010 14:43, Edelson Regis de Lima wrote:
   Boa tarde pessoal!
  
   Já dei uma pesquisada nas mensagens antigas do forum, mas não
  encontrei...
   Alguém sabe se dá para criar um arquivo, e no momento da sua criação
   informar o nome do Autor? (Aquela propriedade que o windows mostra
 quando
   vemos as propriedades do arquivo)
   E também como extrair de um arquivo o nome do Autor.
  
   A data e hora de criação eu já consegui extrair da seguinte maneira:
   FileDateToDateTime(FileAge('Nome_Do_Arquivo'))
  
   Mas preciso extrair também o nome do Autor.
  
   Obrigado!
  
   Edelson.
  
  
   [As partes desta mensagem que não continham texto foram removidas]
  
  
  
   
  
  
 
 
 



 --
 Adriano Santos
 http://twitter.com/asrsantos
 www.delphitodelphi.blogspot.com


 [As partes desta mensagem que não continham texto foram removidas]



 

 --
  FAVOR REMOVER ESTA PARTE AO RESPONDER ESTA MENSAGEM 






[As partes desta mensagem que não continham texto foram removidas]



[delphi-br] Nome do autor de um arquivo

2010-05-26 Por tôpico Edelson Regis de Lima
Boa tarde pessoal!

Já dei uma pesquisada nas mensagens antigas do forum, mas não encontrei...
Alguém sabe se dá para criar um arquivo, e no momento da sua criação
informar o nome do Autor? (Aquela propriedade que o windows mostra quando
vemos as propriedades do arquivo)
E também como extrair de um arquivo o nome do Autor.

A data e hora de criação eu já consegui extrair da seguinte maneira:
FileDateToDateTime(FileAge('Nome_Do_Arquivo'))

Mas preciso extrair também o nome do Autor.

Obrigado!

Edelson.


[As partes desta mensagem que não continham texto foram removidas]