Access .MDB AutoIncrement Column value reset

Október 25th, 2011
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("ALTER TABLE TableName ALTER COLUMN ColumnName AUTOINCREMENT(1,1);"); //(1,1)->The starting value will be 1, and it will increment by 1.
ADOQuery1->ExecSQL();

PDFSharp – Add to exist PDF

Október 25th, 2011
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
using PdfSharp.Drawing;
using System.Diagnostics;
using System.IO;
...
            string file = "test.pdf";
            PdfDocument outputDocument = new PdfDocument();
            PdfDocument doc = PdfSharp.Pdf.IO.PdfReader.Open(file, PdfDocumentOpenMode.Import);
            PdfPage page = doc.Pages[0];

            outputDocument.AddPage(page);
            PdfPage page2 = outputDocument.Pages[0];
            XGraphics gfx = XGraphics.FromPdfPage(page2);
            XImage image = XImage.FromFile("image.jpg");
            gfx.DrawImage(image, 5, 100);

            XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
            XFont font = new XFont("ArialCE", 13, XFontStyle.Regular, options);
            gfx.DrawString("Test text: ľščťžňýáíéúäô - " + DateTime.Now, font, XBrushes.Black, 5, 100);

            if(File.Exists("out.pdf")){File.Delete("out.pdf");}
            outputDocument.Save("out.pdf");

            Process.Start("out.pdf");

(Synapse THTTPSend->Document) TMemoryStream to AnsiString

September 28th, 2011
THTTPSend *http=new(THTTPSend);
AnsiString s;
http->HTTPMethod("GET", "http://ide.as-to.eu/");
s.SetLength(http->Document->Size);
http->Document->Position = 0;
http->Document->Read(s.c_str(), s.Length());
Caption=s;

Integer to time

September 28th, 2011
int sec=72;
ShowMessage(TimeToStr(TimeStampToDateTime(MSecsToTimeStamp(sec*1000+24*3600*1000)))); //show 0:01:12

Search on file

August 31st, 2011
using System.IO;
...
StreamReader testTxt = new StreamReader("test.txt");
string line = "";
while ((line = testTxt.ReadLine()) != null)
{
if (line.Substring(2, 32) == "0D5F86A97FDF0366A3A52BA639F991F3") {MessageBox.Show(line.Substring(38, 9));}
}