Репликация
среда, ноября 26, 2008http://msdn.microsoft.com/ru-ru/library/ms151198(SQL.90).aspx
http://msdn.microsoft.com/ru-ru/library/ms151198(SQL.90).aspx
Function GetFileVersion(Const FileName: String): String;
Type
TFileVersion = Packed Record
Case Integer Of
0: (Ver64: Int64);
1: (VerLS, VerMS: DWORD);
2: (Ver3, Ver2, Ver1, Ver0: Word);
3: (Build, Release, Minor, Major: Word);
End;
Var
VersInfo : Pointer;
VersInfoSize : DWORD;
FileVersion : TFileVersion;
w : DWORD;
FileInfo : PVSFixedFileInfo;
Begin
Result := '';
VersInfoSize := GetFileVersionInfoSize(PChar(FileName), W);
GetMem(VersInfo, VersInfoSize);
Try
If GetFileVersionInfo(PChar(FileName), 0, VersInfoSize, VersInfo) And
VerQueryValue(VersInfo, '\', Pointer(FileInfo), W) Then
Begin
FileVersion.VerMS := FileInfo.dwFileVersionMS;
FileVersion.VerLS := FileInfo.dwFileVersionLS;
Result := Int2Str(FileVersion.Major) + '.' + Int2Str(FileVersion.Minor);
End;
Finally
FreeMem(VersInfo);
End;
End;
function Translit(const Str: string): string;
const
RArrayL = 'абвгдеёжзийклмнопрстуфхцчшщьыъэюя';
RArrayU = 'АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯ';
colChar = 33;
arr: array[1..2, 1..ColChar] of string =
(('a', 'b', 'v', 'g', 'd', 'e', 'yo', 'zh', 'z', 'i', 'y',
'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'f',
'kh', 'ts', 'ch', 'sh', 'shch', '''', 'y', '''', 'e', 'yu', 'ya'),
('A', 'B', 'V', 'G', 'D', 'E', 'Yo', 'Zh', 'Z', 'I', 'Y',
'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'F',
'Kh', 'Ts', 'Ch', 'Sh', 'Shch', '''', 'Y', '''', 'E', 'Yu', 'Ya'));
var
i: Integer;
LenS: Integer;
p: integer;
d: byte;
begin
result := '';
LenS := length(str);
for i := 1 to lenS do
begin
d := 1;
p := pos(str, RArrayL);
if p = 0 then
begin
p := pos(str, RArrayU);
d := 2
end;
if p <> 0 then
result := result + arr[d, p]
else
result := result + str; //если не русская буква, то берем исходную
end;
end;
Решил поработать с любимой диссертацией, столкнулся с проблемой: часть информации была в формате docx, а на компьютере установлен Microsoft Word 2003, который не понимает этот формат.
Нашел элегантное решение: пакет совместимости MS Office 2003 с файлами MS Office 2007 от Майкрософт. Скачиваем 28 мегабайтный дистрибутив, жмем “Установить” и через минуты можно открывать в 2003 офисе документы от 2007. Удобно!
function Xls_To_StringGrid(List: TStringList; AXLSFile: string): Boolean;
const
xlCellTypeLastCell = $0000000B;
var
XLApp, Sheet: OLEVariant;
RangeMatrix: Variant;
x, y, k, r: Integer;
begin
Result := False;
// Create Excel-OLE Object
XLApp := CreateOleObject('Excel.Application');
try
// Hide Excel
XLApp.Visible := False;
// Open the Workbook
XLApp.Workbooks.Open(AXLSFile);
// Sheet := XLApp.Workbooks[1].WorkSheets[1];
Sheet := XLApp.Workbooks[ExtractFileName(AXLSFile)].WorkSheets[1];
// In order to know the dimension of the WorkSheet, i.e the number of rows
// and the number of columns, we activate the last non-empty cell of it
Sheet.Cells.SpecialCells(xlCellTypeLastCell, EmptyParam).Activate;
// Get the value of the last row
x := XLApp.ActiveCell.Row;
// Get the value of the last column
y := XLApp.ActiveCell.Column;
// Assign the Variant associated with the WorkSheet to the Delphi Variant
RangeMatrix := XLApp.Range['A1', XLApp.Cells.Item[X, Y]].Value;
// Define the loop for filling in the TStringGrid
k := 1;
repeat
List.Add(RangeMatrix[K, 1]);
Inc(k, 1);
until k > x;
// Unassign the Delphi Variant Matrix
RangeMatrix := Unassigned;
finally
// Quit Excel
if not VarIsEmpty(XLApp) then
begin
// XLApp.DisplayAlerts := False;
XLApp.Quit;
XLAPP := Unassigned;
Sheet := Unassigned;
Result := True;
end;
end;
end;
sp_adjustpublisheridentityrange
@publication = 'Moscow'