[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "GetSystemDefaultLCID")]
public static extern int GetSystemDefaultLCID();
[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "SetLocaleInfoA")]
public static extern int SetLocaleInfo(int Locale, int LCType, string lpLCData);
public const int LOCALE_STIME = 0x1003;
public void SetDateTimeFormat()
{
try
{
int x = GetSystemDefaultLCID();
SetLocaleInfo(x, LOCALE_STIME, "HH:mm:ss"); //长时间格式 24
/// SetLocaleInfo(x, LOCALE_STIME, "hh:mm:ss"); //短时间格式 12
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
public static extern int GetSystemDefaultLCID();
[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "SetLocaleInfoA")]
public static extern int SetLocaleInfo(int Locale, int LCType, string lpLCData);
public const int LOCALE_STIME = 0x1003;
public void SetDateTimeFormat()
{
try
{
int x = GetSystemDefaultLCID();
SetLocaleInfo(x, LOCALE_STIME, "HH:mm:ss"); //长时间格式 24
/// SetLocaleInfo(x, LOCALE_STIME, "hh:mm:ss"); //短时间格式 12
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}