CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: CONTROL PANEL

  1. #1
    Join Date
    Sep 2001
    Posts
    254

    CONTROL PANEL

    i have written a software that uses DATES and System Dates for calculation and printing formatted as dd/mm/yyyy which is being used for quites sometime, suddenly my programs starts giving wrong results on date calculation as well as in printing. I have discovered that one fkng happy trigger user changed the system date format to mm/dd/yyyy through control panel. Anybody have an idea to protect a software for such unknown changes in system settings.? Is there a way to limit the access of the control panel.?

    thanks


    cyrus




  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: CONTROL PANEL

    Have a look:
    http://www.mvps.org/vbnet/code/locale/setlocaleinfo.htm

    Do your best to have a nice day.

    Cesare Imperiali

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3

    Re: CONTROL PANEL

    ...the regional settings is a service of windows... if U develop in windows U must consider this service.
    For a correct reading of a date U can use function as dateserial,month,year,weekday...

    hi,brt

    <center>
    <HR width=80%>
    <img src='http://web.tiscali.it/bertaplanet/im...ertaplanet.gif'>
    </center>

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: How to know


    Obtaining user regionalSettings:
    http://www.mvps.org/vbnet/code/local...eenumdates.htm

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    Nov 2001
    Posts
    2

    Re: CONTROL PANEL


    'use the following code
    'The declarations
    private Declare Function GetSystemDefaultLCID Lib "kernel32" () as Long
    private Const LOCALE_SSHORTDATE = &H1F ' short date format string
    private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (byval Locale as Long, byval LCType as Long, byval lpLCData as string, byval cchData as Long) as Long
    private Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (byval Locale as Long, byval LCType as Long, byval lpLCData as string) as Long



    ' the function
    private Sub Command1_Click()
    Dim sReturn as string
    Dim r as Long
    Dim LCID as Long
    LCID = GetSystemDefaultLCID()
    r = GetLocaleInfo(LCID, LOCALE_SSHORTDATE, sReturn, len(sReturn))
    If r then
    'pad the buffer with spaces to create the size of memory buffer
    sReturn = Space$(r)
    'and call again passing the buffer
    r = GetLocaleInfo(LCID, LOCALE_SSHORTDATE, sReturn, len(sReturn))
    'if successful (r > 0)
    If r then
    'r holds the size of the string
    'including the terminating null
    If Left$(sReturn, r - 1) <> "dd/MM/yyyy" then
    Call SetLocaleInfo(LCID, LOCALE_SSHORTDATE, "dd/MM/yyyy")
    End If
    End If
    End If
    End Sub





  6. #6
    Join Date
    Mar 2002
    Posts
    4

    Re: CONTROL PANEL

    dear ,
    1.set the data type of date column in table as text.
    2.make use of mask edit control
    3.use only one format say 02-04-2001 in mask edit control
    4.manipulate date by using datevalue function

    have a nice day
    a.k.lakhman
    --------------



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured