帮忙转换两段Delphi代码(转换成C#的),重谢
没接触过Delphi,希望学过的兄弟帮个忙,万分感谢!!
const
titlestr:array[0..15] of byte=
($00,$01,$00,$00,$53,$74,$61,$6E,$64,$61,$72,$64,$20,$4A,$65,$74) ;//对应MDB文件的前16个字节
titlestr2:array[0..15] of byte=
($48,$4A,$00,$58,$55,$43,$48,$41,$4E,$47,$59,$4F,$55,$00,$20,$20) ;//更改后的MDB文件的前16个字节,自己随便写吧,比如写上自己公司的简称或自已的名
produce EncrypMDB(filename:string); //用titlestr2内容替换MDB前16个字节,以便实现加密的作用
var F:TFileStream;
begin
if not fileExists(filename) then exit;
F:=TFileStream.create(filename,fmopenwrite);
try
F.seek($00,soFromBeginning);
F.Write(titlestr2,16);
finally
F.free;
end;
end;
produce uncrypMDB(filename:string); //还原MDB前16个字节
var F:TFileStream;
begin
if not fileExists(filename) then exit;
F:=TFileStream.create(filename,fmopenwrite);
try
F.seek($00,soFromBeginning);
F.Write(titlestr,16);
finally
F.free;
end;
end;
uncrypMDB(App_path+'data\temp.db');
copyfile(pchar(App_path+'data\temp.db'),pchar(APP_path+'\data\account.db'),false);
adoconn.connectionstring:='provider=Microsoft.Jet.OLEDB.4.0;Data Source='+App_path+'data\account.db;Persist Security Info=false'; //adocon是个TADOConnection组件
try
adoconn.connected:=true;
except
MessageBox(handle,'打开数据库出现致命的错误!!!','错误',MB_OK+MB_ICONERROR);
end;
//打开后马上对其加密
copyfile(pchar(APP_path+'\data\account.db'),pchar(app_path+'data\temp.db'),false); //app_path表示程序的当前目录,account.db是个更改了扩展名的MDB文件
EncrypMDB(App_path+'data\temp.db');
copyfile(pchar(App_path+'data\temp.db'),pchar(APP_path+'\data\account.db'),false);
deletefile(App_path+'data\temp.db');
reg:=TRegistry.Create;
try
reg.RootKey:=HKEY_CLASSES_ROOT;
reg.OpenKey('.ldb');
reg.WriteString(','tempfile');
finally
reg.closekey;
reg.free;
end;
const
titlestr:array[0..15] of byte=
($00,$01,$00,$00,$53,$74,$61,$6E,$64,$61,$72,$64,$20,$4A,$65,$74) ;//对应MDB文件的前16个字节
titlestr2:array[0..15] of byte=
($48,$4A,$00,$58,$55,$43,$48,$41,$4E,$47,$59,$4F,$55,$00,$20,$20) ;//更改后的MDB文件的前16个字节,自己随便写吧,比如写上自己公司的简称或自已的名
produce EncrypMDB(filename:string); //用titlestr2内容替换MDB前16个字节,以便实现加密的作用
var F:TFileStream;
begin
if not fileExists(filename) then exit;
F:=TFileStream.create(filename,fmopenwrite);
try
F.seek($00,soFromBeginning);
F.Write(titlestr2,16);
finally
F.free;
end;
end;
produce uncrypMDB(filename:string); //还原MDB前16个字节
var F:TFileStream;
begin
if not fileExists(filename) then exit;
F:=TFileStream.create(filename,fmopenwrite);
try
F.seek($00,soFromBeginning);
F.Write(titlestr,16);
finally
F.free;
end;
end;
uncrypMDB(App_path+'data\temp.db');
copyfile(pchar(App_path+'data\temp.db'),pchar(APP_path+'\data\account.db'),false);
adoconn.connectionstring:='provider=Microsoft.Jet.OLEDB.4.0;Data Source='+App_path+'data\account.db;Persist Security Info=false'; //adocon是个TADOConnection组件
try
adoconn.connected:=true;
except
MessageBox(handle,'打开数据库出现致命的错误!!!','错误',MB_OK+MB_ICONERROR);
end;
//打开后马上对其加密
copyfile(pchar(APP_path+'\data\account.db'),pchar(app_path+'data\temp.db'),false); //app_path表示程序的当前目录,account.db是个更改了扩展名的MDB文件
EncrypMDB(App_path+'data\temp.db');
copyfile(pchar(App_path+'data\temp.db'),pchar(APP_path+'\data\account.db'),false);
deletefile(App_path+'data\temp.db');
reg:=TRegistry.Create;
try
reg.RootKey:=HKEY_CLASSES_ROOT;
reg.OpenKey('.ldb');
reg.WriteString(','tempfile');
finally
reg.closekey;
reg.free;
end;
...全文
相关推荐
Delphi转换C#
Delphi源码转换为C#,最高支持到Delphi2010,破除了原版500行的限制. 因为delphi的控件,C#没有,所以转换的代码不能直接运行,但是可以查看.
C#与***互转工具:代码转换简化
本文还有配套的精品资源,点击获取 简介:在.NET框架下,C#和 是两种广泛使用的编程语言。该互转工具提供CSharp2VB和VB2Csharp两个核心功能,支持将C#代码转换为 代码,以及将***代码转换为C#代码。转换过程尽可能保持代码的可读性和逻辑完整性,某些特性可能需要人工调整。VB2Csharp还支持Delphi和VB6到C#的转换,帮...
delphi to c# 转换代码
delphi to c# 转换代码,对任意DELPHI代码可以转化成C#代码
delphi调用C# DLL
delphi调用C# DLL
delphi代码转成C#的小工具
delphi代码转成C#的小工具 注册版


