+97
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
using System;
using Microsoft.Win32;
namespace Reester
{
class Program
{
static void Main(string[] args)
{
RegCreatySubKey();
}
private static void RegCreatySubKey()
{
RegistryKey regKey = Registry.LocalMachine;
string[] shell = new[] { "SOFTWARE", "Microsoft", "Windows", "CurrentVersion", "Explorer", "CommandStore", "shell" };
string prog = "Programma";
1) using (regKey = Registry.LocalMachine.OpenSubKey(shell[0],true))// тут regKey равно{HKEY_LOCAL_MACHINE}
2) { //сдеть уже regKey равно {HKEY_LOCAL_MACHINE\SOFTWARE}
3) if (regKey != null)//и тут уже regkey равно Null.А дальше программа не идет.
{
using (regKey = Registry.LocalMachine.OpenSubKey(shell[1], true))
{
if (regKey != null)
{
using (regKey = Registry.LocalMachine.OpenSubKey(shell[2], true))
{
if (regKey != null)
{
using (regKey = Registry.LocalMachine.OpenSubKey(shell[3], true))
{
if (regKey != null)
{
using (regKey = Registry.LocalMachine.OpenSubKey(shell[4], true))
{
if (regKey != null)
{
using (regKey = Registry.LocalMachine.OpenSubKey(shell[5], true))
{
if (regKey != null)
{
using (regKey = Registry.LocalMachine.OpenSubKey(shell[6], true))
{
if (regKey != null)
{
regKey.CreateSubKey(prog);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
Работаем с реестром
Psilon,
31 Декабря 2014
+97
- 1
- 2
- 3
- 4
- 5
- 6
if (((((length > 4) && ((anUrl[0] == 'h') || (anUrl[0] == 'H'))) &&
((anUrl[1] == 't') || (anUrl[1] == 'T'))) &&
(((anUrl[2] == 't') || (anUrl[2] == 'T')) &&
((anUrl[3] == 'p') || (anUrl[3] == 'P')))) &&
((anUrl[4] == ':') || (((length > 5) &&
((anUrl[4] == 's') || (anUrl[4] == 'S'))) && (anUrl[5] == ':'))))
Нашел в коде проверку на http(s)
logman,
26 Декабря 2014
+97
- 1
- 2
var
TCPLength: boolean;
Ага. Длина либо есть, либо нет.
youmych,
07 Августа 2014
+97
- 1
- 2
- 3
- 4
- 5
- 6
- 7
Сегодня был приятно удивлен тем, что цикл
for i:=0 to memo1.lines.count -1 do
...
приостанавливает работу, когда идет обращение к мемо (пользователь выделяет текст или печатает в этом мемо) до тех пор, пока идет обращение.
Очевидно, это такая фишка компилятора. Приятно, когда компилятор прикрывает спину.
Stertor,
10 Августа 2013
+97
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
{$APPTYPE CONSOLE} {$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
uses SysUtils, Classes, IniFiles, Variants;
type TGetToken = function(var p: pointer): LongInt;
procedure ParseData(var p: pointer; isKey: boolean); forward;
procedure AdvanceIndex(var i: LongInt); forward;
function GetIntegerToken(var p: pointer): LongInt;
var value: LongInt = 0;
negative: boolean;
begin
Inc(p);
negative := PByte(p)^ = ord('-');
if negative then Inc(p);
repeat
value := value * 10 + LongInt(PByte(p)^ - $30);
Inc(p)
until PChar(p)^ = 'e';
Inc(p);
if negative then value := - value;
Result := value
end;
function GetListToken(var p: pointer): LongInt;
var index: Integer = 0;
begin
Inc(p);
while PChar(p)^ <> 'e' do begin
AdvanceIndex(index);
ParseData(p, false);
end;
Inc(p);
Result := -1
end;
function GetDictToken(var p: pointer): LongInt;
begin
Inc(p);
while PChar(p)^ <> 'e' do begin
ParseData(p, true);
ParseData(p, false);
end;
Inc(p);
Result := -1
end;
function ParseError(var p: pointer): LongInt;
begin
Writeln('TYIIINTE CBET');
Result := -1;
Halt(Result)
end;
const FuncTable: array[0..3] of TGetToken = (ParseError, GetDictToken, GetIntegerToken, GetListToken);
function GetStringToken(var p: pointer): string;
var value: ShortString;
length: LongInt = 0;
begin
repeat
length := length * 10 + LongInt(PByte(p)^ - $30);
Inc(p)
until PChar(p)^ = ':';
if length in [1..255] then begin
PByte(p)^ := length;
Move(p^, value, length+1);
Result := value;
end else Result := 'BINARY DATA';
Inc(p, length + 1);
end;
var sl: TStringList;
outf: TIniFile;
procedure AdvanceIndex(var i: LongInt);
begin
sl.Add(IntToStr(i));
Inc(i);
end;
type TSaveData = procedure(value: Variant);
procedure SaveData(value: Variant);
var
key: string = '';
i: LongInt;
begin
for i := 0 to sl.Count - 1 do key := key + '.' + sl[i];
Delete(key, 1, 1);
outf.WriteString('Torrent', key, VarToStr(value));
if sl.Count > 0 then sl.Delete(sl.Count - 1);
end;
procedure PushKey(value: Variant);
begin
sl.Add(value)
end;
procedure PopKey(value: Variant);
begin
if sl.Count > 0 then sl.Delete(sl.Count - 1);
end;
procedure NOP(value: Variant);
begin
end;
const SaveDataTable: array[0..3] of TSaveData = (SaveData, PushKey, PopKey, NOP);
procedure ParseData(var p: pointer; isKey: boolean);
var
OpCode: ShortInt;
value: Variant;
begin
OpCode := PByte(p)^;
if OpCode >= $60 then value := FuncTable[OpCode shr 2 and 3](p)
else if Opcode in [$30..$39] then value := GetStringToken(p)
else ParseError(p);
SaveDataTable[ord(isKey) + 2*ord(chr(OpCode) in ['d', 'l'])](value);
end;
var f: TFileStream;
s: LongInt;
p, cp: pointer;
begin
if ParamCount <> 1 then Writeln('Usage: ', ParamStr(0), ' filename.torrent')
else
try
f := TFileStream.Create(ParamStr(1), fmOpenRead);
s:= f.Size;
GetMem(p, s + 1);
f.ReadBuffer(p^, s);
cp := p;
outf := TIniFile.Create(ChangeFileExt(ParamStr(1), '.ini'));
sl := TStringList.Create;
ParseData(cp, false);
finally
if sl <> nil then sl.Destroy();
if outf <> nil then outf.Destroy();
if p <> nil then FreeMem(p);
if f <> nil then f.Destroy()
end
end.
Парсер torrent-файлов и сохранялка в INI-файл (пока без сумм фрагментов). Опа-лаба-стайл, писано левой ногой анскильного питуха.
inkanus-gray,
09 Июля 2013
+97
- 1
- 2
- 3
Integer [] jh = new Integer [1];
Integer j0 = new Integer(17);
jh[0]= j0;
Заполняем массив.
3.14159265,
30 Января 2013
+97
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
SetLength(s,N);
SetLength(Y,N);
SetLength(U,N);
SetLength(Z,N);
SetLength(E,N);
for i:=0 to N do //какбэ на выход за границы даже не смотрим, не в этом суть
begin
SetLength(S[i],M);
SetLength(Y[i],M);
SetLength(U[i],M);
SetLength(Z[i],M);
SetLength(E[i],M);
end;
Переделывал чужой консольный проект под форму, не сразу понял, что происходит.
Так вот, Вы, наверное, думаете, что знаете, как задавать размер динамического массива? Нет, нихрена вы не знаете.
SkuII,
29 Мая 2012
+97
- 1
$date_sys=date("20y-m-d");
Код из Марокко. Действительно, зачем юзать Y-m-d, если Y = 20y.
howl,
23 Мая 2012
+97
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
enum TheComponentsOfLanguage
{
Glottis, //— голосовая щель;
FerreinsCord, //— голосовая складка;
VestibularFold, //— складка преддверия;
EpiglotticFold, //— черпалонадгортанная складка;
BaseOfTongue, //— корень языка;
PalatineTonsils, //— небные миндалины;
BlindHoleLanguage, //— слепое отверстие языка;
BorderFurrow, //— пограничная бороздка;
LeafBuds, //— листовидные сосочки;
PapillaeSurroundedTheShaf, //— сосочки, окруженные валом;
MushroomShapedPapillae, //— грибовидные сосочки;
BodyLanguage, //— корпус языка;
FiliformPapillae, //— нитевидные сосочки;
DorsumOfTongue, //— спинка языка;
TheTipOfTheTongue //— верхушка языка;
}
KusokGovna,
17 Мая 2012
+97
- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
namespace Interface.module1
{ class Sort_text
{ private string[] str;
public Sort_text(string[] astr)
{ if (astr.Length == 0)
{ str = new String[1];
str[0] = "";
}
else
{ str = new String[astr.Length];
str = astr; }
}
public string[] Str
{ get { return str; }
set { this.str = value; }
}
public void sort_poslovno_pryamoi()
{ string ss = "";
List<string> t = new List<string>();
for (int i = 0; i < Str.Count(); i++)
for (int j = 0; j < Str[i].Length; j++)
{ if (Str[i][j] == ' ')
{ if (ss == "")
continue;
t.Add(ss);
ss = "";
}
else
{ ss = ss + Str[i][j];
if (j + 1 == Str[i].Length && ss != "")
{ t.Add(ss);
ss = ""; }
}
}
t.Sort();
Str = t.ToArray();
}
public void sort_poslovno_obratnyi()
{ string ss = "";
List<string> t = new List<string>();
for (int i = 0; i < Str.Count(); i++)
for (int j = 0; j < Str[i].Length; j++)
{ if (Str[i][j] == ' ')
{ if (ss == "")
continue;
t.Add(ss);
ss = ""; }
else
{ ss = ss + Str[i][j];
if (j + 1 == Str[i].Length && ss != "")
{ t.Add(ss);
ss = ""; }
}
}
t.Sort();
t.Reverse();
Str = t.ToArray();
}
public void sort_postrochno_pryamoi()
{ string ss = "";
List<string> t = new List<string>();
for (int i = 0; i < Str.Count(); i++)
{ t.Add(Str[i]);
}
t.Sort();
Str = t.ToArray();
}
public void sort_postrochno_obratnyi()
{ string ss = "";
List<string> t = new List<string>();
for (int i = 0; i < Str.Count(); i++)
{ t.Add(Str[i]);
}
t.Sort();
t.Reverse();
Str = t.ToArray();
}
}
class Sort_bin
{ private byte[] b;
public Sort_bin(byte[] ab)
{ b = ab; }
public byte[] B
{ get { return b; }
set { this.b = value; }
}
public void sort_bin_pryamoi()
{ List<byte> t = new List<byte>(B.ToList());
t.Sort();
B = t.ToArray();
}
public void sort_bin_obratnyi()
{ List<byte> t = new List<byte>(B.ToList());
t.Sort();
t.Reverse();
B = t.ToArray(); }
}
}
legati,
12 Мая 2012