Autor Beitrag
Biarchiv
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Di 06.08.02 12:51 
Hallo,

Habe folgende Code und Procenduren.
Wie kann ich die Datei im Stream öffnen ohne sie auf die Platte zu schreiben.
Also shw so umschreiben das ich diese aus einen Stream öffnen kann.
Ist das auch für Procedure Decrypt möglich?
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
procedure ShW(FileName: string; Params: string); 
var 
exInfo: TShellExecuteInfo; 
Ph: DWORD; 
Msg : TMsg; 

begin 
FillChar(exInfo, SizeOf(exInfo), 0); 
with exInfo do 
begin 
cbSize := SizeOf(exInfo); 
fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT; 
Wnd := GetActiveWindow(); 
ExInfo.lpVerb := 'open'; 
ExInfo.lpParameters := PChar(Params); 
lpFile := PChar(FileName); 
nShow := SW_SHOWNORMAL; 
end; 
if ShellExecuteEx(@exInfo) then 
Ph := exInfo.HProcess 
else 
begin 
// ShowMessage(SysErrorMessage(GetLastError)); 
Exit; 
end; 
while WaitForSingleObject(ExInfo.hProcess, 50) <> WAIT_OBJECT_0 do 
// while PeekMessage(Msg, 0, 0, 0, 0) do 
// begin 
TranslateMessage(Msg); 
DispatchMessage(Msg); 
// end; 
//Application.ProcessMessages; 
CloseHandle(Ph); 
end; 

function Decrypt(const S: String; Key: Word): String; 
var 
I: Integer; 
begin 
Result := S; 
for I := 1 to Length(S) do 
begin 
Result[I] := char(byte(S[I]) xor (Key shr 8)); 
Key := (byte(S[I]) + Key) * C1 + C2; 
end; 
end; 
procedure DecryptFile(INFName, OutFName : String; Key : Word); 
VAR 
MS, SS : TMemoryStream; 
X : Integer; 
C, O : Byte; 
begin 
MS := TMemoryStream.Create; 
SS := TMemoryStream.Create; 
TRY 
MS.LoadFromFile(INFName); 
MS.Position := 0; 
FOR X := 0 TO MS.Size - 1 DO 
begin 
MS.Read(C, 1); 
O := C; 
C := (C xor (Key shr 8)); 
Key := (O + Key) * C1 + C2; 
SS.Write(C,1); 
end; 
SS.SaveToFile(OutFName); 
FINALLY 
SS.Free; 
MS.Free; 
end; 
end;


Code-Tags hinzugefügt. Tino