Search Results

Search found 3 results on 1 pages for 'tdatetime'.

Page 1/1 | 1 

  • Delphi - Frac function losing precision.

    - by PeteDaMeat
    I have a TDateTime variable which is assigned a value at runtime of 40510.416667. When I extract the time to a TTime type variable using the Frac function, it sets it to 0.41666666666. Why has it changed the precision of the value and is there a workround to retain the precision from the original value ie. to set it to 0.416667.

    Read the article

  • calling delphi dll from c#

    - by Wouter Roux
    Hi, I have a Delphi dll defined like this: TMPData = record Lastname, Firstname: array[0..40] of char; Birthday: TDateTime; Pid: array[0..16] of char; Title: array[0..20] of char; Female: Boolean; Street: array[0..40] of char; ZipCode: array[0..10] of char; City: array[0..40] of char; Phone, Fax, Department, Company: array[0..20] of char; Pn: array[0..40] of char; In: array[0..16] of char; Hi: array[0..8] of char; Account: array[0..20] of char; Valid, Status: array[0..10] of char; Country, NameAffix: array[0..20] of char; W, H: single; Bp: array[0..10] of char; SocialSecurityNumber: array[0..9] of char; State: array[0..2] of char; end; function Init(const tmpData: TMPData; var ErrorCode: integer; ResetFatalError: boolean = false): boolean; procedure GetData(out tmpData: TMPData); My current c# signatures looks like this: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct TMPData { [MarshalAs(UnmanagedType.LPStr, SizeConst = 40)] public string Lastname; [MarshalAs(UnmanagedType.LPStr, SizeConst = 40)] public string Firstname; [MarshalAs(UnmanagedType.R8)] public double Birthday; [MarshalAs(UnmanagedType.LPStr, SizeConst = 16)] public string Pid; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string Title; [MarshalAs(UnmanagedType.Bool)] public bool Female; [MarshalAs(UnmanagedType.LPStr, SizeConst = 40)] public string Street; [MarshalAs(UnmanagedType.LPStr, SizeConst = 10)] public string ZipCode; [MarshalAs(UnmanagedType.LPStr, SizeConst = 40)] public string City; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string Phone; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string Fax; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string Department; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string Company; [MarshalAs(UnmanagedType.LPStr, SizeConst = 40)] public string Pn; [MarshalAs(UnmanagedType.LPStr, SizeConst = 16)] public string In; [MarshalAs(UnmanagedType.LPStr, SizeConst = 8)] public string Hi; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string Account; [MarshalAs(UnmanagedType.LPStr, SizeConst = 10)] public string Valid; [MarshalAs(UnmanagedType.LPStr, SizeConst = 10)] public string Status; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string Country; [MarshalAs(UnmanagedType.LPStr, SizeConst = 20)] public string NameAffix; [MarshalAs(UnmanagedType.I4)] public int W; [MarshalAs(UnmanagedType.I4)] public int H; [MarshalAs(UnmanagedType.LPStr, SizeConst = 10)] public string Bp; [MarshalAs(UnmanagedType.LPStr, SizeConst = 9)] public string SocialSecurityNumber; [MarshalAs(UnmanagedType.LPStr, SizeConst = 2)] public string State; } [DllImport("MyDll.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool Init(TMPData tmpData, int ErrorCode, bool ResetFatalError); [DllImport("MyDll.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetData(out TMPData tmpData); I first call Init setting the BirthDay, LastName and FirstName. I then call GetData but the TMPData structure I get back is incorrect. The FirstName, LastName and Birthday fields are populated but the data is incorrect. Is the mapping correct? ( "array[0..40] of char" equal to "[MarshalAs(UnmanagedType.LPStr, SizeConst = 40)]" )?

    Read the article

  • delphi idhttp post related question

    - by paul
    hello All im new to delphi. and also almost new to programming world. i was made some simple post software which using idhttp module. but when execute it , it not correctly working. this simple program is check for my account status. if account login successfully it return some source code which include 'top.location =' in source, and if login failed it return not included 'top.location =' inside account.txt is follow first and third account was alived account but only first account can check, after first account other account can't check i have no idea what wrong with it ph896011 pk1089 fsadfasdf dddddss ph896011 pk1089 following is source of delphi if any one help me much apprecated! unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, IdCookieManager, ExtCtrls; type TForm1 = class(TForm) Button1: TButton; IdHTTP1: TIdHTTP; Memo1: TMemo; IdCookieManager1: TIdCookieManager; lstAcct: TListBox; result: TLabel; Edit1: TEdit; Timer1: TTimer; procedure Button1Click(Sender: TObject); //procedure FormCreate(Sender: TObject); //procedure FormClose(Sender: TObject; var Action: TCloseAction); private { Private declarations } public AccList: TStringList; IdCookie: TIdCookieManager; CookieList: TList; StartCnt: Integer; InputCnt: Integer; WordList: TStringList; WordNoList: TStringList; WordCntList: TStringList; StartTime: TDateTime; end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var i: Integer; //temp: String; lsttemp: TStringList; sl : tstringlist; //userId,userPass: string; begin InputCnt:= 0; WordList := TStringList.Create; CookieList := TList.create; IdCookie := TIdCookieManager.Create(self); if FileExists(ExtractFilePath(Application.ExeName) + 'account.txt') then WordList.LoadFromFile(ExtractFilePath(Application.ExeName) + 'account.txt'); WordNoList:= TStringList.Create; WordCntList := TStringList.Create; lsttemp := TStringList.create; sl :=Tstringlist.Create; try try for i := 0 to WordList.Count -1 do begin ExtractStrings([' '], [' '], pchar(WordList[i]), lsttemp); WordNoList.add(lsttemp[0]); //ShowMessage(lsttemp[0]); WordCntList.add(lsttemp[1]); //ShowMessage(lsttemp[1]); sl.Add('ID='+ lsttemp[0]); sl.add('PWD=' + lsttemp[1]); sl.add('SECCHK=0'); IdHTTP1.HandleRedirects := True; IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded'; memo1.Text:=idhttp1.Post('http://user.buddybuddy.co.kr/Login/Login.asp',sl); if pos('top.location =',Memo1.Text)> 0 then begin application.ProcessMessages; ShowMessage('Alive Acc!'); //result.Caption := 'alive acc' ; sleep(1000); Edit1.Text := 'alive acc'; lsttemp.Clear; Memo1.Text := ''; //memo1.Text := IdHTTP1.Get('https://user.buddybuddy.co.kr/Login/Logout.asp'); Sleep(1000); end; if pos('top.location =', memo1.Text) <> 1 then begin application.ProcessMessages; ShowMessage('bad'); Edit1.Text := 'bad'; //edit1.Text := 'bad'; lsttemp.Clear; memo1.Text := ''; sleep(1000) ; end; Edit1.Text := ''; end; finally lsttemp.free; end; StartCnt := lstAcct.items.Count; StartTime := Now; finally sl.Free; end; end; end.

    Read the article

1