Uzun zaman önce bir batch file gibi görev yapan bir programım vardı. Bu programımı derlediğim zaman kullandığımız antivirus yazılımı oluşan exe dosyayı bir virus olarak değerlendiriyor ve siliyor. Şirketteki antivurus yazılımını değiştirmek gibi bir şansım yok. Bu konuya nasıl bir çözüm sağlayabilirim fikri olan var mi?
Selamlar, hayırlı cumalar.
Delphi 2007 kodları:
Kod: Tümünü seç
program ERPStart;
uses
SysUtils,
Windows,
Forms;
function GetEnvVar(
const csVarName : string ) : string;
const
{
change the following value if you
expect more than 250 char values
from env. vars. set to 250 by
default to be compatible with
16bit versions of Delphi
}
cnMaxVarValueSize = 250;
{$IFDEF WIN32}
var
pc1,
pc2 : PChar;
begin
{
although you can use huge strings with
Delphi 2.x, we'll use good old PChars
and allocate memory here
}
pc1 :=
StrAlloc( Length( csVarName )+1 );
pc2 :=
StrAlloc( cnMaxVarValueSize + 1 );
StrPCopy( pc1, csVarName );
GetEnvironmentVariableA(
pc1, pc2, cnMaxVarValueSize );
Result := StrPas( pc2 );
StrDispose( pc1 );
StrDispose( pc2 );
end;
{$ELSE}
var
w1 : Word;
pc1 : PChar;
begin
GetEnvVar := '';
w1 := Length( csVarName );
{$IFDEF Windows}
pc1 := GetDosEnvironment;
{$ELSE}
pc1 :=
Ptr(Word( Ptr( PrefixSeg, $2C )^),
0 );
{$ENDIF}
while( #0 <> pc1^ ) do
begin
if( 0 = StrLIComp( pc1,
@csVarName[ 1 ], w1 ) )
and ( '=' = pc1[ w1 ] ) then
begin
GetEnvVar :=
StrPas( pc1 + w1 + 1 );
Exit;
end;
Inc( pc1, StrLen( pc1 ) + 1 );
end;
GetEnvVar := '';
end;
{$ENDIF}
procedure Calistir;
var
v,pth:String;
begin
pth:=ExtractFilePath(Application.ExeName);
chdir(pth);
v:=GetEnvVar('TEMP');
v:=v+'\ERP.Exe';
CopyFile(pchar(pth+'App\ERP.Exe'),PChar(v),false);
v:=v+' '+pth;
WinExec(PChar(v),SW_SHOWNORMAL);
end;
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
try
{ TODO -oUser -cConsole Main : Insert code here }
Calistir;
except
on E:Exception do
Writeln(E.Classname, ': ', E.Message);
end;
Application.Run;
end.