Str:=  '2010-4-13  06:22:22'; StrToDateTime(Str); 现象:在WinXP, Win2003 都不会报错 但是在Windows7,Windows Server 2008 上,报 ‘xxx’  is not a valid  date and time  错误 后来发现不同操作系统的默认的 短日期样式 是不同的 WinXP, Win2003 默认短日期样式是 xxxx-xx-xx Windows7, Windows Server 2008 默认短日期样式…
var    FSetting : TFormatSettings;    DateTime1: tDateTime;  begin    FSetting := TFormatSettings.Create(LOCALE_USER_DEFAULT);    FSetting.ShortDateFormat:='yyyy-MM-dd';    FSetting.DateSeparator:='-';    //FSetting.TimeSeparator:=':';    FSetting.Lo…
在Delphi中,特别是在写管理系统软件时,经常要用到 FormatDateTime 以将 TDateTime 格式的日期时间转换成字符串形式的值显示或保存起来,或者用 StrToDateTime将字符串形式的日期时间转换成 TDateTime 然后再做其他操作. 在进行时间或日期的转换时,会使用系统当前设定的时间日期格式.而如果时间日期格式与字符串中的表示方式不相符,会使转换过程失败.例如当前短日期格式设定为'yyyy/MM/dd',而要转为 '2006-10-20'这样的字符串为日期,就会报…
FormatDateTime('yyyy-mm-dd hh:nn:ss',Now) FormatDateTime('hh:mm:ss:zz',Now) if (TimeOf(now) < pub_StartWorkTime) or (TimeOf(now) > pub_EndWorkTime) then exit; //非工作时间退出 读ini pub_StartWorkTime := MyIniFile.Readtime('Setup','StartWorkTime',strtotime('…
unit Unit1; interface uses   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type   TForm1 = class(TForm)     btn1: TButton;     btn2: TButton;    …
转换GMT秒数为日期时间格式-Delphi源码.收藏最近在写PE分析工具的时候,需要转换TimeDateStamp字段值为日期时间格式,这是Delphi的源码. //把GMT时间的秒数转换成日期时间格式function GetGMTDateTime(Value:Int64):TDateTime;var Year,Month,Day:Word; Hour,Min,Sec,MSec:Word; iYear,iDay:Word; iHour,iMin,iSec:Word; RInt,i:Integer…
{-----------------------------------------------------------------------------作者:sushengmiyan 2013.01.26备注:功能:硬件信息获取单元-----------------------------------------------------------------------------} unit ApplicationHardWareInfo; interfaceuses Windows,…
delphi  RAD Studio Berlin 10.1 主要是FireMonkey 移动开发的改动,VCL确实没有多大变化. http://docwiki.embarcadero.com/RADStudio/Berlin/en/Main_Page http://docwiki.embarcadero.com/RADStudio/Berlin/en/What's_New EMB 官网地址资源 Bug fix list for RAD Studio 10.1 Berlin http://edn…
//提示:此代码需要use Registry, Common; function WriteMAC(model:integer):integer; var reg:TRegistry; begin reg:=TRegistry.Create; //创建注册表对象 reg.RootKey:=HKEY_LOCAL_MACHINE; //指定注册表根为HKLM if reg.OpenKey('\System\CurrentControlSet\Control\Class\ {4D36E972-E325…
假如操作系统的日期格式不是yyyy-MM-dd格式,而是用strtodate('2014-10-01')) 来转换的话,程序会提示爆粗 '****-**-**'is not a valid date and time 解决方法: 只需要在程序启动时添加以下代码,就可以不用修改系统日期和时间格式,就能解决上述报错 DateSeparator := '-';//日期分隔符 LongDateFormat := 'yyyy-MM-dd'; //长日期格式 ShortDateFormat := 'yyyy…