Delphi使用StrToDatetime在不同操作系统出现不同的情况(控制面板的时间格式都记录在注册表里,因此也可修改注册表)
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 默认短日期样式是 xxxx/x/xx
可以通过 控制面板---->区域设置------->日期----->短日期样式 查看
为了程序有更好的兼容性,可以进行注册表修改
HKEY_CURRENT_USER/Control Panel/International其中的sDate项将其值强制设置成'/',
这个办法不是非常好,最好的是程序做判断,适应系统,而不是更改系统设置来适应程序
http://blog.csdn.net/missmecn/article/details/5870591
Delphi使用StrToDatetime在不同操作系统出现不同的情况(控制面板的时间格式都记录在注册表里,因此也可修改注册表)的更多相关文章
- Delphi中StrToDateTime函数TFormatSettings参数的使用
var FSetting : TFormatSettings; DateTime1: tDateTime; begin FSetting := TFormatSettings.Cr ...
- Delphi获取与设置系统时间格式,即GetLocaleInfo和SetLocaleInfo
在Delphi中,特别是在写管理系统软件时,经常要用到 FormatDateTime 以将 TDateTime 格式的日期时间转换成字符串形式的值显示或保存起来,或者用 StrToDateTime将字 ...
- delphi 时间格式操作
FormatDateTime('yyyy-mm-dd hh:nn:ss',Now) FormatDateTime('hh:mm:ss:zz',Now) if (TimeOf(now) < pub ...
- Delphi获得与设置系统时间格式《转》
unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, Syst ...
- 转换GMT秒数为日期时间格式-Delphi源码
转换GMT秒数为日期时间格式-Delphi源码.收藏最近在写PE分析工具的时候,需要转换TimeDateStamp字段值为日期时间格式,这是Delphi的源码. //把GMT时间的秒数转换成日期时间格 ...
- 获取硬件信息的delphi源码CPUID、操作系统、Mac物理地址、计算机名称、IP地址、用户名
{-----------------------------------------------------------------------------作者:sushengmiyan 2013.0 ...
- delphi RAD Studio新版本及路线图 及官方网站 官方 版本发布时间
delphi RAD Studio Berlin 10.1 主要是FireMonkey 移动开发的改动,VCL确实没有多大变化. http://docwiki.embarcadero.com/RAD ...
- 贴一份用delphi修改注册表改网卡MAC地址的代码
//提示:此代码需要use Registry, Common; function WriteMAC(model:integer):integer; var reg:TRegistry; begin r ...
- 不修改系统日期和时间格式,解决Delphi报错提示 '****-**-**'is not a valid date and time
假如操作系统的日期格式不是yyyy-MM-dd格式,而是用strtodate('2014-10-01')) 来转换的话,程序会提示爆粗 '****-**-**'is not a valid date ...
随机推荐
- java--继承的一些笔记
public class Person { public void display(){ System.out.println("Play Person..."); } stati ...
- 在Myeclipse中安装java Decompiler
由于在myeclipse中的Help选项中没有Install New Software,所以在eclipse中安装插件的方法并不适应于Myeclipse,但是我们可以通过点击Windows->P ...
- POJ 1700 cross river (数学模拟)
...
- Android基础总结(精华完整版)
1. 前言 1.1. 什么是3G.4G Ÿ 第三代移动通信技术(3rd - Generation),速率一般在几百Kbps,较之前的2G和2.5G在数据传输速度上有很大提升. Ÿ 第四代移动通信技术( ...
- hdu 4861 Couple doubi(数论)
题目链接:hdu 4861 Couple doubi 题目大意:两个人进行游戏,桌上有k个球,第i个球的值为1i+2i+⋯+(p−1)i%p,两个人轮流取,假设DouBiNan的值大的话就输出YES, ...
- Android-onInterceptTouchEvent()和onTouchEvent()总结
老实说,这两个小东东实在是太麻烦了,很不好懂,我自己那api文档都头晕,在网上找到很多资料,才知道是怎么回事,这里总结一下,记住这个原则就会很清楚了: 1.onInterceptTouchEvent( ...
- PHP - 递归函数
/** * factorial($num) 计算阶乘 * @param string $num * @return string $total */ function factorial($num) ...
- One simple health check for oracle with sql
There are some sqls which is used for check the oracle database's health condition. ------numbers of ...
- POJ 1258-Agri-Net (Kruskal)
题目链接:Agri-Net 最小生成树水题,数组开的和题目描写叙述一样,可是就是RE,有填了个0,还好这个题用 库鲁斯卡尔 敲了一遍,发现了点问题,曾经写的库鲁卡尔模板有点问题,多写了步没用的操作,已 ...
- C#2.0--集合--转载车老师
集合在编程的过程中用的是非常的多,如GridViewRowCollection.ConnectionStringSettingsCollection.NameValueCollection等等.一般来 ...