?? unit1.pas
字號:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, NMURL, Menus, Buttons,ShlObj, ExtCtrls, Gauges,shellapi,registry;
type
TForm1 = class(TForm)
NMURL1: TNMURL;
Image1: TImage;
Label1: TLabel;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
MainMenu1: TMainMenu;
N1: TMenuItem;
N3: TMenuItem;
N9: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N10: TMenuItem;
N4: TMenuItem;
N2: TMenuItem;
N5: TMenuItem;
Gauge1: TGauge;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
procedure N4Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses register;
{$R *.dfm}
function BrowseFolder:string;
var
Info:TBrowseInfo; // 加ExtDlgs 單元 ShlObj,
Dir:array[0..260] of char;
ItemId:PItemIDList;
begin
with Info do
begin
hwndOwner:=Form1.Handle;
pidlRoot:=nil;
pszDisplayName:=nil;
lpszTitle:='請選擇保存目錄:';
ulFlags:=0;
lpfn:=nil;
lParam:=0;
iImage:=0;
end;
ItemId:=SHBrowseForFolder(Info);
if ItemId<>nil then
begin
SHGetPathFromIDList(ItemId,@Dir);
Result:=string(Dir);
end;
end;
procedure TForm1.N4Click(Sender: TObject);
begin
exit;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
OpenDialog1.Execute;
SpeedButton2.Enabled:=true;
SpeedButton3.Enabled:=true;
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
var
dir:string;
i,j:integer;
strlist:tstringlist;
myfilename,tempstr,listtemp:string;
Reg:TRegistry;
myRegstr:string;
function encodeurl(urlstr: string):string; //---------encodeurl
var
onelist:tstringlist;
twolist:tstringlist;
mytemp,onetemp:string;
i,total:integer;
begin
onelist:= TStringList.Create;
twolist:= TStringList.Create;
mytemp:=urlstr; //輸入未加密
total:=length(mytemp);
i:=1;
while i<=total do
begin
if ord(mytemp[i])<=126 then //不是中文
begin
onetemp:='';
while (i<=total) and (ord(mytemp[i])<=126) do //--判斷
begin
onetemp:=onetemp+mytemp[i];
i:=i+1;
end;
NMURL1.InputString:=onetemp;
onelist.Add(NMURL1.Encode); //加入第一個鏈表
end //end不是中文
else
begin
onetemp:='';
while (i<=total) and (ord(mytemp[i])>126) do //--判斷
begin
onetemp:=onetemp+mytemp[i];
i:=i+1;
end;
twolist.Add(onetemp); //加入第一個鏈表
end //end是中文
end;//endwhile
mytemp:='';
i:=0;
while (i<onelist.Count) or (i<twolist.Count) do //把字符串裝配起來
begin
if i<onelist.Count then
mytemp:=mytemp+onelist.Strings[i];
if i<twolist.Count then
mytemp:=mytemp+twolist.Strings[i];
i:=i+1;
end;//endwhile
onelist.Free;
twolist.Free;
result:=mytemp; //輸出 加密
end;
begin //++++++++++++++++++++++++++++++++++加密+++++++++++++++++++++++++++++++++
if OpenDialog1.Files.Count=0 then
begin
MessageBox(form1.Handle,'至少選擇一個文件','網頁加密',MB_ok or
MB_ICONQUESTION);
exit;
end;
Dir:=BrowseFolder;
if dir='' then
begin
MessageBox(form1.Handle,'請選擇目錄','網頁加密',MB_ok or
MB_ICONQUESTION);
exit;
end;
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_LOCAL_MACHINE;
Reg.OpenKey('SOFTWARE\Microsoft\DataAccess\RootBinder\nds',True);
myRegstr:=Reg.readstring('set');
reg.CloseKey;
Reg.Free;
if myRegstr<>'1' then
begin
if OpenDialog1.Files.Count>1 then
begin
MessageBox(form1.Handle,'未注冊用戶每次只能選擇一個文件,如你想獲得軟件的完整功能,請注冊本軟件!','網頁加密',MB_ok or
MB_ICONQUESTION);
SpeedButton2.Enabled:=false;
SpeedButton3.Enabled:=false;
exit;
end;
end;
Gauge1.Visible:=true;
Gauge1.MinValue:=0;
Gauge1.MaxValue:=OpenDialog1.Files.Count;
for i:=0 to OpenDialog1.Files.Count-1 do
begin
strlist:= TStringList.Create;
strlist.LoadFromFile(OpenDialog1.Files.Strings[i]); //讀入文件
strlist.Text:=encodeurl(strlist.Text); //加密
tempstr:='';
listtemp:=strlist.Text;
for j:=1 to strlen(pchar(listtemp)) do
begin
if listtemp[j]='+' then
tempstr:=tempstr+' '
else if (listtemp[j]<>#13) and (listtemp[j]<>#10) then
tempstr:=tempstr+listtemp[j];
end;
tempstr:='<SCRIPT>var Words="'+tempstr+'";document.write(unescape(Words))</SCRIPT>';
strlist.Text:=tempstr;
myfilename:=ExtractFileName(OpenDialog1.Files.Strings[i]);
myfilename:=dir+'\'+myfilename;
if FileExists(myfilename) then
begin
tempstr:=myfilename+#13+'此文件已存在,是否覆蓋';
case Application.MessageBox(pchar(tempstr),'資料管理器',MB_YESNO or
MB_ICONQUESTION) of
IDyes:
begin
FileSetAttr(myfilename,faArchive); //去掉只讀屬性
DeleteFile(myfilename);
end;
end;
end;
strlist.SaveToFile(myfilename);
Gauge1.Progress:=Gauge1.Progress+1;
end; //endfor
sleep(1000);
Gauge1.Visible:=false;
Gauge1.Progress:=0;
SpeedButton2.Enabled:=false;
SpeedButton3.Enabled:=false;
end; //+++++++++++++++++++++++++++++++加密+++++++++++++++++++++++++++++++++++++++
procedure TForm1.SpeedButton3Click(Sender: TObject);
var
dir:string;
i,j:integer;
strlist:tstringlist;
myfilename,tempstr,listtemp:string;
Reg:TRegistry;
myRegstr:string;
function Decodeurl(urlstr: string):string; //---------Decodeurl
var
onelist:tstringlist;
twolist:tstringlist;
mytemp,onetemp:string;
i,total:integer;
begin
onelist:= TStringList.Create;
twolist:= TStringList.Create;
mytemp:=urlstr; //輸入未加密
total:=length(mytemp);
i:=1;
while i<=total do
begin
if ord(mytemp[i])<=126 then //不是中文
begin
onetemp:='';
while (i<=total) and (ord(mytemp[i])<=126) do //--判斷
begin
onetemp:=onetemp+mytemp[i];
i:=i+1;
end;
NMURL1.InputString:=onetemp;
onelist.Add(NMURL1.Decode); //加入第一個鏈表
end //end不是中文
else
begin
onetemp:='';
while (i<=total) and (ord(mytemp[i])>126) do //--判斷
begin
onetemp:=onetemp+mytemp[i];
i:=i+1;
end;
twolist.Add(onetemp); //加入第一個鏈表
end //end是中文
end;//endwhile
mytemp:='';
i:=0;
while (i<onelist.Count) or (i<twolist.Count) do //把字符串裝配起來
begin
if i<onelist.Count then
mytemp:=mytemp+onelist.Strings[i];
if i<twolist.Count then
mytemp:=mytemp+twolist.Strings[i];
i:=i+1;
end;//endwhile
onelist.Free;
twolist.Free;
result:=mytemp; //輸出 加密
end;
begin //++++++++++++++++++解密++++++++++++++++++++++++++++++++++++++++++++++
if OpenDialog1.Files.Count=0 then
begin
MessageBox(form1.Handle,'至少選擇一個文件','網頁加密',MB_ok or
MB_ICONQUESTION);
exit;
end;
Dir:=BrowseFolder;
if dir='' then
begin
MessageBox(form1.Handle,'請選擇目錄','網頁加密',MB_ok or
MB_ICONQUESTION);
exit;
end;
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_LOCAL_MACHINE;
Reg.OpenKey('SOFTWARE\Microsoft\DataAccess\RootBinder\nds',True);
myRegstr:=Reg.readstring('set');
reg.CloseKey;
Reg.Free;
if myRegstr<>'1' then
begin
if OpenDialog1.Files.Count>1 then
begin
MessageBox(form1.Handle,'未注冊用戶每次只能選擇一個文件,如你想獲得軟件的完整功能,請注冊本軟件!','網頁加密',MB_ok or
MB_ICONQUESTION);
SpeedButton2.Enabled:=false;
SpeedButton3.Enabled:=false;
exit;
end;
end;
Gauge1.Visible:=true;
Gauge1.MinValue:=0;
Gauge1.MaxValue:=OpenDialog1.Files.Count;
for i:=0 to OpenDialog1.Files.Count-1 do
begin
strlist:= TStringList.Create;
strlist.LoadFromFile(OpenDialog1.Files.Strings[i]); //讀入文件
strlist.Text:=Decodeurl(strlist.Text); //解密
tempstr:='';
listtemp:=strlist.Text;
{
for j:=1 to strlen(pchar(listtemp)) do
begin
if listtemp[j]='+' then
tempstr:=tempstr+' '
else if (listtemp[j]<>#13) and (listtemp[j]<>#10) then
tempstr:=tempstr+listtemp[j];
end;
strlist.Text:=tempstr; }
delete(listtemp,1,19);
delete(listtemp,strlen(pchar(listtemp))-43,43);
strlist.Text:=listtemp;
myfilename:=ExtractFileName(OpenDialog1.Files.Strings[i]);
myfilename:=dir+'\'+myfilename;
if FileExists(myfilename) then
begin
tempstr:=myfilename+#13+'此文件已存在,是否覆蓋';
case Application.MessageBox(pchar(tempstr),'資料管理器',MB_YESNO or
MB_ICONQUESTION) of
IDyes:
begin
FileSetAttr(myfilename,faArchive); //去掉只讀屬性
DeleteFile(myfilename);
end;
end;
end;
strlist.SaveToFile(myfilename);
Gauge1.Progress:=Gauge1.Progress+1;
end; //endfor
sleep(1000);
Gauge1.Visible:=false;
Gauge1.Progress:=0;
SpeedButton2.Enabled:=false;
SpeedButton3.Enabled:=false;
end; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -