- localizar - regedit.exe
Computador\HKEY_CURRENT_USER\Software\Borland\Delphi\6.0 - localizar
LM - REG_BINARY
DELETE
Delphi e Aplicativos nao acessam discos mapeados
Acesse o RegEdit.exe, localizar o seguinte diretório Computador\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System , nele, crie um registro chamado "EnableLinkedConnections" do tipo DWORD (32 bits), com valor 1. Feito isso, basta reiniciar o computador.
nome do diretório onde esta o executavel
ExtractFilePath(Application.ExeName)
var vMatriz : Array[0..99] of String;
for x01 := 0 to 99 do
vMatriz[x01]:=''
data do executavel corrente
formatDateTime('dd/mm/yyyy hh:nn',FileDateToDateTime(FileAge(application.ExeName)))
data de um arquivo qualquer ( o arquivo deve existir se não da pau )
formatDateTime('dd/mm/yyyy hh:nn',FileDateToDateTime(FileAge('c:\autoexec.bat')));
// AAMMDDHHMMSSMMM ( milisegudos )
formatDateTime('yyyymmddhhnnsszzz',now()));
arquivo: existe no diretorio do executavel
formatDateTime('dd/mm/yyyy hh:nn',FileDateToDateTime(FileAge('c:\autoexec.bat')));
// AAMMDDHHMMSSMMM ( milisegudos )
formatDateTime('yyyymmddhhnnsszzz',now()));
arquivo: existe no diretorio do executavel
fileExists(ExtractFilePath(Application.ExeName)+'telesql.par')
Path do: diretorio do executavel ( ex: C:\PROJETO\TESTE\ ) este é o retorno
ExtractFilePath(Application.ExeName)
ExtractFilePath(Application.ExeName)
arquivo: copia um arquivo de: c:\projeto\teste\a.txt p/ c:\temp\b.txt
copyFile(StrToPchar('c:\projeto\teste\a.txt'),
StrToPchar('c:\temp\b.txt'),
false);
extrai o nome do arquivo sem o path
Exemplo: c:\autoexec.bat
Var:=ExtractFileName(Exemplo)
Retorno: autoexec.bat
copyFile(StrToPchar('c:\projeto\teste\a.txt'),
StrToPchar('c:\temp\b.txt'),
false);
extrai o nome do arquivo sem o path
Exemplo: c:\autoexec.bat
Var:=ExtractFileName(Exemplo)
Retorno: autoexec.bat
Delete um arquivo
deleteFile(vArqDestino);
altera a extensão de um arquivodeleteFile(vArqDestino);
ChangeFileExt('c:\autoexec.bat','.bck');
arquivo: renome um arquivo de: a.txt p/ b.txt
extensão de um arquivo
ExtractFileExt('c:\autoexec.bat');
renameFile('a.txt','b.txt');
move um arquivo de: c:\projeto\teste\a.txt p/ c:\temp\b.txt
moveFile(StrToPchar('c:\projeto\teste\a.txt'),
StrToPchar('c:\temp\b.txt'));
executa um arquivo exe sem paramentros
moveFile(StrToPchar('c:\projeto\teste\a.txt'),
StrToPchar('c:\temp\b.txt'));
executa um arquivo exe sem paramentros
winExec(StrToPchar(arq),SW_SHOW)
executa um arquivo exe com paramentros
Arq := 'teleped.exe '+parametro;
winExec(StrToPchar(arq),SW_SHOW);
ou
var vhelp : Pchar;
begin // ALTERA AQUI
if not fileExists(parDirHelp+'\arq.html') then
msg('Arquivo de help solicitado : '+parDirHelp+'\arq.html')
else
begin
screen.cursor:=crhourglass;
vhelp:=strToPchar(parDirHelp+'\arq.html');
ShellExecute(Handle, 'Open', vHelp, nil, nil, SW_SHOW);
screen.cursor:=crDeFault;
end;
end;
carrega um arquivo para um memo
Arq := 'teleped.exe '+parametro;
winExec(StrToPchar(arq),SW_SHOW);
ou
var vhelp : Pchar;
begin // ALTERA AQUI
if not fileExists(parDirHelp+'\arq.html') then
msg('Arquivo de help solicitado : '+parDirHelp+'\arq.html')
else
begin
screen.cursor:=crhourglass;
vhelp:=strToPchar(parDirHelp+'\arq.html');
ShellExecute(Handle, 'Open', vHelp, nil, nil, SW_SHOW);
screen.cursor:=crDeFault;
end;
end;
carrega um arquivo para um memo
mparametro.Lines.LoadFromFile('telesql.par');
for x01:=0 to (mparametro.Lines.Count-1) do
begin
mparametro.Lines.Strings[x01];
end;
mparametro.Lines.SaveToFile('arquivo.txt');
for x01 := Length( sValor ) downto 1 do
begin
if ( sValor[ x01 ] <> '.' ) and ( sValor[ x01 ] <> ',' ) then
sDec := sValor[ x01 ] + sDec
else
Break;
end;
for x01:=0 to (mparametro.Lines.Count-1) do
begin
mparametro.Lines.Strings[x01];
end;
mparametro.Lines.SaveToFile('arquivo.txt');
for x01 := Length( sValor ) downto 1 do
begin
if ( sValor[ x01 ] <> '.' ) and ( sValor[ x01 ] <> ',' ) then
sDec := sValor[ x01 ] + sDec
else
Break;
end;
arquivo texto - ABRE
var
arqTxt
: TextFile;
try
AssignFile(arqTxt,arq);
Reset(arqTxt);
while not Eof(arqTXT) do
begin
readln(arqTXT,vstr);
....
end
finally
closeFile(arqTxt);
end;
arqTxt
: TextFile;
try
AssignFile(arqTxt,arq);
Reset(arqTxt);
while not Eof(arqTXT) do
begin
readln(arqTXT,vstr);
....
end
finally
closeFile(arqTxt);
end;
arquivo texto - CRIA
var
arqTxt
: TextFile;
try
AssignFile(arqTxt,arq);
Rewrite(arqTxt);
write(arqTxt,'|');
writeln(arqTxt,'');
finally
closeFile(arqTxt);
end;
arquivo existe
: TextFile;
try
AssignFile(arqTxt,arq);
Rewrite(arqTxt);
write(arqTxt,'|');
writeln(arqTxt,'');
finally
closeFile(arqTxt);
end;
arquivo existe
fileExists('c:\autoexec.bat')
// resultado: True/False
// resultado: True/False
cursor
screen.cursor:=crhourglass;
screen.cursor:=crSQLWait;
screen.cursor:=crDeFault;
screen.cursor:=crSQLWait;
screen.cursor:=crDeFault;
parametros em um executave
// 1º paramentro não passado
if ParamStr(1)='' then
exit;
componente ADO
componente ADO
dbSQLLOCAL.BeginTrans;
try
dbSQLLOCAL.CommitTrans;
except
dbSQLLOCAL.RollbackTrans;
end;
// query com passagem de parametros
qDELITEM.Parameters.ParamByName('VCNPJVAR').Value :=vvCNPJVAR;
// atribui valor ao campo (tabela deve estar em edit)
QSSPEDIDO.FieldByName('COLUNA').AsString:='aa';
cria diretorio temporario do windows c:\temp
try
dbSQLLOCAL.CommitTrans;
except
dbSQLLOCAL.RollbackTrans;
end;
// query com passagem de parametros
qDELITEM.Parameters.ParamByName('VCNPJVAR').Value :=vvCNPJVAR;
// atribui valor ao campo (tabela deve estar em edit)
QSSPEDIDO.FieldByName('COLUNA').AsString:='aa';
cria diretorio temporario do windows c:\temp
vdir := 'c:\temp';
if not DirectoryExists(vdir) then
try
MkDir(vdir);
except
vRetorno:=False;
end;
if not DirectoryExists(vdir) then
try
MkDir(vdir);
except
vRetorno:=False;
end;
tquery
QTabela.Close;
QTabela.ParamByName('pCODASS').Value:= edCodigo.Text;
QTabela.Open;
QTabela.Open;
ado
qVVACESSO.Close;
qVVACESSO.Parameters.ParamByName('VFORMULA').Value:=Nome;
qVVACESSO.Open;
qVVACESSO.Parameters.ParamByName('VFORMULA').Value:=Nome;
qVVACESSO.Open;
qConsulta.FieldByName('CPF_TITULAR').AsString;
tratamento global de erro
type
TFrmPrincipal = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
Procedure TrataErros(Sender:TObject;E:Exception);
end;
procedure TFrmPrincipal.TrataErros(Sender: TObject; E: Exception);
begin
MessageBox(Handle,PChar('Erro interno no sistema da classe:'+#10+E.ClassName),'Erro interno',MB_ICONERROR+MB_OK)
end;
procedure TFrmPrincipal.FormCreate(Sender: TObject);
begin
Application.OnException:=TrataErros;
end;
dbgridTFrmPrincipal = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
Procedure TrataErros(Sender:TObject;E:Exception);
end;
procedure TFrmPrincipal.TrataErros(Sender: TObject; E: Exception);
begin
MessageBox(Handle,PChar('Erro interno no sistema da classe:'+#10+E.ClassName),'Erro interno',MB_ICONERROR+MB_OK)
end;
procedure TFrmPrincipal.FormCreate(Sender: TObject);
begin
Application.OnException:=TrataErros;
end;
begin
if qConsulta.Active then
if (qConsulta.RecordCount>0) then
begin
EdCodigo.Text:=QConsulta.FieldByName('CNPJ_ADM').AsString;
carrega();
pcConsulta.ActivePageIndex:=1;
editaChave(0);
end;
end;
procedure TFRMConsulta.dbgConsultaDrawColumnCell(..
begin
dbgConsulta.Canvas.Font.Color:= clBlue;
dbgConsulta.Canvas.Font.Style:=[];
if (qConsulta.FieldByName('BLOQBAND').AsString='S') then
dbgConsulta.Canvas.Font.Color:= clRed;
if (qConsulta.FieldByName('STATUS').AsString<>'A') then
dbgConsulta.Canvas.Font.Color:= clSilver;
if gdSelected in State then
dbgConsulta.Canvas.Brush.Color := clAqua;
dbgConsulta.Canvas.FillRect(Rect);
dbgConsulta.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
procedure TFrmInstituicao.dbgConsultaEnter(....;
begin
DOSMOVE.Active:=False;
end;
procedure TFrmInstituicao.dbgConsultaExit(...
begin
DOSMOVE.Active:=True;
end;
oracle - disparo de store procedures
sp1.Close;
sp1.ParamByName('P_PERIODO').AsString:='A';
sp1.ParamByName('P_NRDIAS').AsFloat:=1;
sp1.ExecProc;
edit1.Text:=sp1.ParamByName('Result').Value;
disparo com ADO
sp2.Close;
sp2.Parameters.ParamByName('P_PERIODO').Value:='A';sp2.Parameters.ParamByName('P_NRDIAS').Value:=1;
sp2.ExecProc;
edit2.Text:=sp2.Parameters.ParamByName('RETURN_VALUE').Value;
SQL-SERVER - disparo de store procedures
SPNEXTVAL.Close;
SPNEXTVAL.ParamByName('@VTABELA').AsString := 'PF';
SPNEXTVAL.ExecProc;
SPNEXTVAL.GetResults;
VAR:= SPNEXTVAL.ParamByName('@CODIGO').AsFloat;
SPNEXTVAL.ParamByName('@VTABELA').AsString := 'PF';
SPNEXTVAL.ExecProc;
SPNEXTVAL.GetResults;
VAR:= SPNEXTVAL.ParamByName('@CODIGO').AsFloat;
disparo de store procedure - ADO
SPNEXTVAL.Close;
SPNEXTVAL.Parameters.ParamByName('@VTABELA').Value := 'PF';SPNEXTVAL.ExecProc;
VAR:=SPNEXTVAL.Parameters.ParamByName('@RETURN_VALUE').Value;
BLABLA
TEXTO
TEXTO