Всем добрый день помогите мне переделать код с delphi на С# .
1) проверка версии
Код:
procedure TForm1.FormCreate(Sender: TObject);
var
ver: string;
http_up: THTTPSend;
reslist: TStringList;
Stream:TMemoryStream;
begin
ver := 'V8.4S';
http_up := THTTPSend.Create;
reslist := TStringList.Create;
try
http_up.HTTPMethod('Get', 'http://*****************/Warface/Ver.txt');
reslist.LoadFromStream(http_up.Document);
if trim(reslist.text) <> ver then begin
application.Terminate;
Application.CreateForm(TForm1, Form1);
end;
except
application.Terminate;
Application.CreateForm(TForm1, Form1);
end;
http_up.Free;
reslist.Free;
end;
2) Код на рандомное значение окна
Код:
function RandomPassword(PLen: Integer): string;
var
str: string;
begin
Randomize;
//string with all possible chars
str := '12345QWAESTZFDCVYGHBNMJIO#$LKM';
Result := '22';
repeat
Result := Result + str[Random(Length(str)) + 1];
until (Length(Result) = PLen)
end;
function RandomWord(dictSize, lngStepSize, wordLen, minWordLen: Integer): string;
begin
Result := '';
if (wordLen < minWordLen) and (minWordLen > 0) then
wordLen := minWordLen
else if (wordLen < 1) and (minWordLen < 1) then wordLen := 1;
repeat
Result := Result + Chr(Random(dictSize) + lngStepSize);
until (Length(Result) = wordLen);
end;
3) на Кил процесс
Код:
function KillProcess(ExeName: string): LongBool;
var
B: BOOL;
ProcList: THandle;
PE: TProcessEntry32;
begin
Result := False;
ProcList := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PE.dwSize := SizeOf(PE);
B := Process32First(ProcList, PE);
while B do begin
if (UpperCase(PE.szExeFile) = UpperCase(ExtractFileName(ExeName))) then
Result := TerminateProcess(OpenProcess($0001, False, PE.th32ProcessID), 0);
B := Process32Next(ProcList, PE);
end;
CloseHandle(ProcList);
end;
function processExists(exeFileName: string): Boolean;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
Result := False;
while Integer(ContinueLoop) <> 0 do
begin
if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
UpperCase(ExeFileName))) then
begin
Result := True;
end;
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;
Код:
if processExists('Game.exe') then
ShowMessage('Warface будет закрыта');
KillProcess('Game.exe');
Закрытие по заголовку
4)
Код:
SendMessage(FindWindow(nil, 'DEDE'), WM_CLOSE, 0, 0);
Запрет на изменение название приложения win Form
5)
Код:
procedure TForm1.tmr1Timer(Sender: TObject); // Таймер
Var
h : THandle;
begin
if ExtractFileName(Application.ExeName)<> 'Imperial.exe' then
begin
Application.Terminate;
CloseHandle(h);
end;
end;
6)
Код:
procedure TForm1.btn3Click(Sender: TObject);.//кнопка
var
buttonSelected : Integer;
begin
if processExists('Game.exe') then
else
ShowMessage('Запустите игру');
ShellExecute(Handle, 'open','mailrugames://play/0.1177', nil, nil, SW_SHOWNORMAL);
end;
Помогите пожалуйста )
Готов заплатить, хоть тут и не раздел фриланс!
Умел бы переделывать переделал бы сам..
А то я с delphi ушел перешел на си шарп а проект свой сейчас пытаюсь раздербанить да в паблик!