From: Nathan Baker on
Perhaps a more correct example wouldn't hurt...

program duration;
#include("stdlib.hhf")
#include("w.hhf")

static
siP :w.STARTUPINFO;
piP :w.PROCESS_INFORMATION;
CreateTime :w.FILETIME;
ExitTime :w.FILETIME;
KernelTime :w.FILETIME;
UserTime :w.FILETIME;
MCreateTime :w.SYSTEMTIME;
MExitTime :w.SYSTEMTIME;

begin duration;

w.CreateProcess( null, "dxdiag", null, null, false, w.CREATE_NO_WINDOW,
null, null, &siP, &piP );
w.WaitForSingleObject( piP.hProcess, w.INFINITE );
w.GetProcessTimes( piP.hProcess, CreateTime, ExitTime, KernelTime,
UserTime );
w.FileTimeToSystemTime( CreateTime, MCreateTime );
w.FileTimeToSystemTime( ExitTime, MExitTime );

stdout.puts( "Create -- " );
stdout.put( "H :", MCreateTime.wHour, " " );
stdout.put( "M :", MCreateTime.wMinute, " " );
stdout.put( "S :", MCreateTime.wSecond, nl, nl );

stdout.puts( "Exit -- " );
stdout.put( "H :", MExitTime.wHour, " " );
stdout.put( "M :", MExitTime.wMinute, " " );
stdout.put( "S :", MExitTime.wSecond, nl, nl );

mov( 60, ebx );
movzx( MExitTime.wHour, eax );
movzx( MExitTime.wMinute, edi );
movzx( MExitTime.wSecond, esi );
mul( ebx );
add( edi, eax );
mul( ebx );
add( esi, eax );
mov( eax, ecx );

movzx( MCreateTime.wHour, eax );
movzx( MCreateTime.wMinute, edi );
movzx( MCreateTime.wSecond, esi );
mul( ebx );
add( edi, eax );
mul( ebx );
add( esi, eax );

sub( eax, ecx );

stdout.put( "Duration: $", ecx, " seconds.", nl );

mov( ecx, eax );
cdq();
div( ebx );
mov( edx, esi );
cdq();
div( ebx );

stdout.puts( "Hr: " );
stdout.puti32( eax );
stdout.puts( " Min: " );
stdout.puti32( edx );
stdout.puts( " Sec: " );
stdout.puti32( esi );
stdout.newln();

end duration;


Nathan.


From: Mint on
Has anyone worked with GetProcessTimes?
I need helping fixing this.

I wanted to know how long my browser has been open.

Thanks,
Andy

; test.asm
;

include \masm32\include\masm32rt.inc


printf MACRO format:REQ, args:VARARG
IFNB <args>
invoke crt_printf, cfm$(format), args
ELSE
invoke crt_printf, cfm$(format)
ENDIF
ENDM

..DATA

szCommandLine BYTE "C:\Program Files\Mozilla Firefox\firefox.exe",0
creationTime dq 0
sysTime dq 0
runTime REAL8 ?
hProcess dd 0

..code

start:

Begin PROC

LOCAL SystemInfo:STARTUPINFO
LOCAL ProcessInfo:PROCESS_INFORMATION

MOV SystemInfo.cb, SIZEOF SystemInfo
INVOKE GetStartupInfo, ADDR SystemInfo
OR SystemInfo.dwFlags,STARTF_USESHOWWINDOW
MOV SystemInfo.wShowWindow, SW_HIDE

; start firefox
INVOKE CreateProcess,NULL,ADDR szCommandLine, NULL, NULL, FALSE, \
NORMAL_PRIORITY_CLASS, NULL, NULL, ADDR SystemInfo, ADDR
ProcessInfo

invoke GetCurrentProcessId

invoke OpenProcess, PROCESS_QUERY_INFORMATION, FALSE, eax
mov hProcess, eax

invoke GetProcessTimes, hProcess, ADDR creationTime, ADDR sysTime,
ADDR sysTime, ADDR sysTime

invoke GetSystemTimeAsFileTime, ADDR sysTime

fild sysTime
fild creationTime
fsub
fld8 100.0e-9
fmul
fstp runTime

printf "%.1fs\n\n", runTime

inkey "Press any key to exit..."
exit

Begin endp

end start
From: io_x on
VOID GetSystemTime(
LPSYSTEMTIME lpSystemTime // address of system time structure
);
i'm sure nobody like what i do;
in one asm file
i call GetSystemTime, than convert the structure LPSYSTEMTIME
to one C++ class data that descrive second, min, hour, day, month, year
(easy because class data is easy to follow)

when i want a "delta" recall GetSystemTime
and full one other class object of kind second, min, hour, day, month, year

than i call one C++ "-" functions put in one one .dll
for the two dates (in the asm file always), and find the
difference in second, hour, day, month year
or something of that kind :)

"Mint" <chocolatemint77581(a)yahoo.com> ha scritto nel messaggio
news:398915b2-8e99-4488-88d2-9f670b9a8f36(a)g19g2000yqc.googlegroups.com...
> Has anyone worked with GetProcessTimes?
> I need helping fixing this.
>
> I wanted to know how long my browser has been open.
>
> Thanks,
> Andy
>
> ; test.asm
> ;
>
> include \masm32\include\masm32rt.inc
>
>
> printf MACRO format:REQ, args:VARARG
> IFNB <args>
> invoke crt_printf, cfm$(format), args
> ELSE
> invoke crt_printf, cfm$(format)
> ENDIF
> ENDM
>
> .DATA
>
> szCommandLine BYTE "C:\Program Files\Mozilla Firefox\firefox.exe",0
> creationTime dq 0
> sysTime dq 0
> runTime REAL8 ?
> hProcess dd 0
>
> .code
>
> start:
>
> Begin PROC
>
> LOCAL SystemInfo:STARTUPINFO
> LOCAL ProcessInfo:PROCESS_INFORMATION
>
> MOV SystemInfo.cb, SIZEOF SystemInfo
> INVOKE GetStartupInfo, ADDR SystemInfo
> OR SystemInfo.dwFlags,STARTF_USESHOWWINDOW
> MOV SystemInfo.wShowWindow, SW_HIDE
>
> ; start firefox
> INVOKE CreateProcess,NULL,ADDR szCommandLine, NULL, NULL, FALSE, \
> NORMAL_PRIORITY_CLASS, NULL, NULL, ADDR SystemInfo, ADDR
> ProcessInfo
>
> invoke GetCurrentProcessId
>
> invoke OpenProcess, PROCESS_QUERY_INFORMATION, FALSE, eax
> mov hProcess, eax
>
> invoke GetProcessTimes, hProcess, ADDR creationTime, ADDR sysTime,
> ADDR sysTime, ADDR sysTime
>
> invoke GetSystemTimeAsFileTime, ADDR sysTime
>
> fild sysTime
> fild creationTime
> fsub
> fld8 100.0e-9
> fmul
> fstp runTime
>
> printf "%.1fs\n\n", runTime
>
> inkey "Press any key to exit..."
> exit
>
> Begin endp
>
> end start




From: Nathan on
On Jun 5, 10:09 am, Mint <chocolatemint77...(a)yahoo.com> wrote:
> Has anyone worked with GetProcessTimes?
> I need helping fixing this.
>
> I wanted to know how long my browser has been open.
>
> Thanks,
>               Andy
>
> ; test.asm
> ;
>
>  include \masm32\include\masm32rt.inc
>
> printf MACRO format:REQ, args:VARARG
>       IFNB <args>
>         invoke crt_printf, cfm$(format), args
>       ELSE
>         invoke crt_printf, cfm$(format)
>       ENDIF
>     ENDM
>
> .DATA
>
> szCommandLine  BYTE   "C:\Program Files\Mozilla Firefox\firefox.exe",0
> creationTime   dq 0
> sysTime        dq 0
> runTime        REAL8 ?
> hProcess       dd 0
>
> .code
>
> start:
>
> Begin PROC
>
> LOCAL SystemInfo:STARTUPINFO
> LOCAL ProcessInfo:PROCESS_INFORMATION
>
>   MOV SystemInfo.cb, SIZEOF SystemInfo
>   INVOKE GetStartupInfo, ADDR SystemInfo
>   OR SystemInfo.dwFlags,STARTF_USESHOWWINDOW
>   MOV SystemInfo.wShowWindow, SW_HIDE
>
> ; start firefox
> INVOKE CreateProcess,NULL,ADDR szCommandLine, NULL, NULL, FALSE, \
>        NORMAL_PRIORITY_CLASS, NULL, NULL, ADDR SystemInfo, ADDR
> ProcessInfo
>
> invoke GetCurrentProcessId
>
>     invoke OpenProcess, PROCESS_QUERY_INFORMATION, FALSE, eax
>     mov hProcess, eax
>
>     invoke GetProcessTimes, hProcess, ADDR creationTime, ADDR sysTime,
>                             ADDR sysTime, ADDR sysTime
>
>     invoke GetSystemTimeAsFileTime, ADDR sysTime
>
>     fild sysTime
>     fild creationTime
>     fsub
>     fld8 100.0e-9
>     fmul
>     fstp runTime
>
>     printf "%.1fs\n\n", runTime
>
>     inkey "Press any key to exit..."
>     exit
>
> Begin   endp
>
> end     start

This HLA program works:

program duration;
#include("stdlib.hhf")
#include("w.hhf")

static
siP :w.STARTUPINFO;
piP :w.PROCESS_INFORMATION;
CreateTime :w.FILETIME;
ExitTime :w.FILETIME;
KernelTime :w.FILETIME;
UserTime :w.FILETIME;
Measured :w.SYSTEMTIME;

begin duration;

w.CreateProcess( null, "notepad", null, null, false,
w.CREATE_NO_WINDOW, null, null, &siP, &piP );
w.WaitForSingleObject( piP.hProcess, w.INFINITE );
w.GetProcessTimes( piP.hProcess, CreateTime, ExitTime, KernelTime,
UserTime );
w.FileTimeToSystemTime( ExitTime, Measured );

stdout.put( Measured.wSecond, nl );

end duration;

Nathan.
From: Herbert Kleebauer on
Mint wrote:
>
> Has anyone worked with GetProcessTimes?
> I need helping fixing this.
>
> I wanted to know how long my browser has been open.

I don't think assembly is the proper language for
this purpose. I suppose you don't care about
summer/winter time or a time greater 24 hours.
In this case a simple batch script should be
sufficient:

echo off
setlocal
for /f "tokens=1-3 delims=0123456789 " %%i in ("%time%") do set d=%%i%%j%%k%

call :tim 1
echo firefox start at %h1%:%m1%:%s1%
start "" /w firefox
call :tim 2
echo firefox stop at %h2%:%m2%:%s2%

set /a s=1%s2%-1%s1%
set /a m=1%m2%-1%m1%
set /a h=1%h2%-1%h1%

if %s% lss 0 (set /a s=s+60
set /a m=m-1)
if %m% lss 0 (set /a m=m+60
set /a h=h-1)
if %h% lss 0 set /a h=h+24

echo online %h%:%m%:%s%
goto :eof

:tim
for /f "tokens=1-3 delims=%d% " %%i in ("%time%") do (
set h=0%%i
set m=0%%j
set s=0%%k)
set h%1=%h:~-2%
set m%1=%m:~-2%
set s%1=%s:~-2%