FUNC.PAS in pedump192(2).zip
Sponsored links
unit func;
interface
uses
Sysutils, Windows, Controls, Registry, Inifiles, Forms;
function MyPath:String;
function DirectoryExists(const Name: String): Boolean;
procedure AssocExeDllFile(Add_Del:Boolean);
implementation
function MyPath:String;
begin
Result:=ExtractFilePath(ParamStr(0));
if Result[Length(Result)]<>'\' then
Result:=Result+'\';
end;
function DirectoryExists(const Name: String): Boolean;
var
Code: Integer;
begin
Code := GetFileAttributes(PChar(Name));
Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
end;
procedure AssocExeDllFile(Add_Del:Boolean);
var
Reg:TRegistry;
Key1,Key2:String;
begin
Reg:=TRegistry.Create;
try
Reg.RootKey:=HKEY_CLASSES_ROOT;
Key1:='\exefile\Shell\用 PEDUMP 分析';
Key2:='\dllfile\Shell\用 PEDUMP 分析';
if Add_Del then
begin{Add}
Reg.OpenKey(Key1+'\Command',True);
Reg.WriteString('',Application.ExeName+' "%1"');
Reg.OpenKey(Key2+'\Command',True);
Reg.WriteString('',Application.ExeName+' "%1"');
end else
begin{Delete}
Reg.OpenKey(Key1+'\Command',True);
Reg.DeleteKey(Key1);
Reg.OpenKey(Key2+'\Command',True);
Reg.DeleteKey(Key2);
end;
Reg.CloseKey;
finally
Reg.Free;
end;
end;
procedure SetWinPos(WinForm:TForm);
var
StrPos,StrScr:String;
begin
{left,top,width,height}
StrPos:=Format('%d,%d,%d,%d',[WinForm.Left,WinForm.Top,WinForm.Width,WinForm.Height]);
StrScr:=Format('WinPos(%d,%d)',[Screen.Width,Screen.Height]);
with TInifile.Create(MyPath+'pedump.ini') do
begin
WriteString('pedump',StrScr,StrPos);
end;
end;
procedure GetWinPos(WinForm:TForm);
const
SEP=',';
var
i:Integer;
StrPos,StrScr:String;
begin
StrScr:=Format('WinPos(%d,%d)',[Screen.Width,Screen.Height]);
with TInifile.Create(MyPath+'pedump.ini') do
begin
StrPos:=ReadString('pedump',StrScr,'0,0,0,0');
end;
{left}
i:=Pos(SEP,StrPos);
// if i=0 then raise Er
...
...
... to be continued.
This is a preview. To get the complete source file,
please click here to download the whole source code package.