How to Set System Time and Date using a Form or Control from ATEasy
Raz A.
Haifa,

Jun 22, 2020
75 Posts

How to Set System Time and Date using a Form or Control from ATEasy

Is there a form\control for setting the time and date?

DrATEasy (Ron Y.)
Mission Viejo, CA

Jun 23, 2020
319 Posts

Re: How to Set System Time and Date using a Form or Control from ATEasy

Need to define some Windows API. But you can use the following:

! open control panel applet to change date time and time zone
WinExec("timedate.cpl")

! set parent to the test exec form
Delay(1000) ! let the window create before we can find it
h=FindWindow(0, "Date and Time")
SetWindowLong(h, -8, TestExec.GetCurrentForm().hWnd)

! disable current form
TestExec.GetCurrentForm().Enabled=False

! Wait until Date/time window closed
while IsWindow(h)
DoEvents()
endwhile

! re-enable
TestExec.GetCurrentForm().Enabled=True

Alternatively you can use the Windows API SetSystemTime defined in Kernel32.dll (see https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-setsystemtime), you will have to provide your own form to set it.

*Changed by Moderator

Raz A.
Haifa,

Jun 24, 2020
75 Posts

Re: How to Set System Time and Date using a Form or Control from ATEasy

I cannot use the functions "FindWindow" ,"SetWindowLong" and "IsWindow"
They do not exists.
What do i need to import?

Solution Available
DrATEasy (Ron Y.)
Mission Viejo, CA

Jun 24, 2020
319 Posts

Re: How to Set System Time and Date using a Form or Control from ATEasy

Edit and Text format and add the following section to the Libraries section:

DLL User32
--------------------------------------------------------------------------------
    File = User32.dll
    ReloadOnStart = False
    LoadOnAccess = True
    Public = True

DLL Types
--------------------------------------------------------------------------------

enumGetWindow: Enum Public
{
    GW_OWNER: Long Const = 4
}

DLL Procedures
--------------------------------------------------------------------------------


Procedure FindWindow(szClassName, sWindowName): AHandle Public Alias = FindWindowA
--------------------------------------------------------------------------------
    szClassName: Val Long
    sWindowName: Val String



Procedure IsWindow(hWnd): Bool Public
--------------------------------------------------------------------------------
    hWnd: Val AHandle

Procedure SetWindowLong(hWnd, lIndex, dwNewLong): Long Public Alias = SetWindowLongA
--------------------------------------------------------------------------------
    hWnd: Val AHandle
    lIndex: Val Long
    dwNewLong: Val DWord



Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]