[pascal]
var
sFormName:String;
i:integer;
begin
sFormName:= Self.Name; // 表單名稱
for i:=0 to self.ComponentCount -1 do begin
if Components[i] is TLabel then begin
if (TLabel(components[i]).Caption <>”) then begin
TLabel(components[i]).Caption := 取得語系….;
end;
end;
if Components[i] is TButton then begin
if (TButton (components[i]).Caption <>”) then begin
TButton (components[i]).Caption := 取得語系….;
end;
end;
end;
end;
[/pascal]
wwDBGrid的話關鍵有:
s:= TwwDBGrid(Components[i]).DataSource.DataSet.Fields[j].FieldName;
TwwDBGrid(Components[i]).ColumnByName(s).DisplayLabel
TwwDBGrid(Components[i]).ColumnByName(s).GroupName
[pascal]
var
astream : Tmemorystream;
begin
AStream := TMemoryStream.Create;
try
astream.LoadFromFile(filename);
AStream.Position := 0;
if adotable1.Active then
begin
adotable1.Edit;
TBlobField(adotable1.FieldByName(‘t2’)).LoadFromStream(AStream);
adotable1.Post;
end;
finally
AStream.free;
end;
end;
[/pascal]
存回檔案
[pascal]
var
Ms:Tmemorystream;
begin
Ms := Tmemorystream.Create;
try
if adotable1.Active then
begin
TBlobField(adotable1.FieldByName(‘t2’)).SaveToStream(Ms);
Ms.Position := 0;
MS.SaveToFile(sname);
end;
finally
ms.Free;
end;
end;
[/pascal]
[php]
// 使用COM調用Dll
$Rockey = new COM("Com.CRockey4ND") or die("<h3>無法初始化保護鎖元件</h3>");
$Rockey->p1 = new VARIANT(0xc44c, VT_UI2);
$Rockey->p2 = new VARIANT(0xc8f8, VT_UI2);
$Rockey->p3 = new VARIANT(0x0799, VT_UI2);
$Rockey->p4 = new VARIANT(0xc43b, VT_UI2);
Delphi
Delphi的方式則有二種:一種是以Dcu一種是載入Dll
Dcu(Delphi Compiled Unit)要先把Rockey4ND.dcu複製到開發的資料夾。
DLL則是要把Rockey4ND.dll複製到開發的資料夾。
DCU寫法
1.Use rockey4nd;
2.宣告
mBuf:array[0..100] of Byte;
mFun,mP1,mP2,mP3,mP4,rt:Word;
lP1,lP2:LongWord;
mHand:array[0..16] of Word;
mHardID:array[0..16] of LongWord;
rc:array[0..4] of Word;
[pascal]
R4ND_Init(); //初始化
mP1:=$c44c;
mP2:=$c8f8;
mP3:=$799;
mP4:=$c43b;
for i:=0 to 30 do
mBuf[i]:=0;
rt:=0;
// 尋找是否有插Keypro
mFun:=1;
rt:= Rockey(mFun,mHand[0],lP1,lP2,mP1,mP2,mP3,mP4,mBuf[0]);
if rt<>0 then
begin
FmtStr(str,’cannot find ROCKEY1,error:%d ‘,[rt]);
List.Items.Add(str);
exit;
end;
List.Items.Add(‘find ROCKEY No.1’);
[/pascal]
DLL寫法
[pascal]
mBuf:array[0..100] of Byte;
mFun,mP1,mP2,mP3,mP4,rt:Word;
lP1,lP2:LongWord;
mHand:array[0..16] of Word;
mHardID:array[0..16] of LongWord;
rc:array[0..4] of Word;
function Rockey(fun:Word; var Handle:Word;
var lp1,lp2:LongWord;
var P1,P2,P3,P4:Word;
var buf:Byte):Word;
stdcall;external ‘Rockey4ND.dll’;
[/pascal]
[pascal]
mP1:=$c44c;
mP2:=$c8f8;
mP3:=$799;
mP4:=$c43b;
for i:=0 to 30 do
mBuf[i]:=0;
rt:=0;
mFun:=1;
rt:= Rockey(mFun,mHand[0],lP1,lP2,mP1,mP2,mP3,mP4,mBuf[0]);
if rt<>0 then
begin
FmtStr(str,’not find ROCKEY1,error:%x ‘,[rt]);
List.Items.Add(str);
exit;
end;
List.Items.Add(‘Find the first ROCKEY’);
[/pascal]
存入
[php]
var astream : Tmemorystream;
begin
AStream := TMemoryStream.Create;
try
Image1.Picture.Graphic.SaveToStream(AStream);
AStream.Position := 0;
if adoquery1.Active then
begin
adoquery1.Edit;
TBlobField(adoquery1.FieldByName(‘File’)).LoadFromStream(AStream);
adoquery1.Post;
end;
finally
AStream.Free;
end;
[/php]
取出
[php]
var
Ms:TStringStream;
jpg1:Tjpegimage;
begin
Ms := TStringStream.Create(”);
jpg1 := Tjpegimage.create;
try
if adoquery1.Active then
begin
TBlobField(adoquery1.FieldByName(‘File’)).SaveToStream(Ms);
Ms.Position := 0;
jpg1.LoadFromStream(ms);
image1.Picture.Bitmap.Assign(jpg1);
end;
finally
ms.Free;
jpg1.Free;
end;
[/php]
注意,如果出現Got a packet bigger than ‘max_allowed_packet’ bytes
在My.ini加上
max_allowed_packet = 10M