#!hs2 ######################################################################## # Script : Fritzweb_Online.hsm # Purpose : Test if Fritzweb is or may go online # (detects which Connection it will use) # Time-stamp: ######################################################################## # NOTE: none ######################################################################## #!load hamster.hsm #!debug 1 #!initialize debug( 255, "<<< module 'Fritzweb_Online.hsm' >>>" ) HamRequireVersion( "1.3.21.0", True ) varset($fritzweb_db_time,0) varset($fritzweb_last_online,0) varset($fritzweb_last_connection,0) return(0) sub FritzWebIsRunning() var($exitcode) #return (1) # assume Fritzweb is always running # this uses pv.exe to determine if FritzWeb is running # get it from http://www.teamcti.com/ (it's freeware) debug(2,"call pv.exe") execute("C:\UT\PRCVIEW\PV.EXE FRIWEB32.EXE", "C:\UT\\", 0, true, $exitcode) debug(2,"Fritzweb running? $exitcode="+$exitcode) return($exitcode=0) endsub # ------------------------------------------------------- # sub StartFritzWeb($mode) # ------------------------------------------------------- # start fritzweb in $mode # current $mode's: # mail (normal exchange) # quickmail (short exchange) # $mode is only used to select different providers and # you may ignore it # ------------------------------------------------------- sub StartFritzWeb($mode) if (FritzWebIsRunning()==0) var($exitcode) debug(1,"Now starting Fritz!Web ("+$mode+") ...") # replace next line by sth that starts FritzWeb on your system: execute("C:\UT\RUN\RUN.EXE "+HamPath+"\StartFritz.bat "+$mode, HamPath, 0,true,$exitcode) endif endsub sub FritzWebDetect(*$online,*$connection) var($output,$failed,$exitcode,$fritzweb_db_curtime) if (FritzWebIsRunning()) $failed = 1 $output = HamPath+"\online.ini" $fritzweb_db_curtime = FileTime("C:\Programme\FRITZ!\FRIWEBEV.DBF") # Fritz!Web Database didn't change since last check if ($fritzweb_db_curtime==$fritzweb_db_time) $online = $fritzweb_last_online $connection = $fritzweb_last_connection else if (FileExists($output)=1) FileDelete($output) endif # ---- customize the following line by setting the correct path: debug(2,"calling fw_cost") execute("C:\UT\RS\FW_COST.EXE -i C:\UT\WinBatches\fw_cost.ini -o "+$output, HamPath, 0, true,$exitcode) if ($exitcode=0 && FileExists($output)=1) var($c,$o) $c = IniRead($output, "", "zugang", "error") $o = IniRead($output, "", "online", "error") $failed = 0 $online = $o $connection = $c # store results for next quickcheck $fritzweb_db_time = $fritzweb_db_curtime $fritzweb_last_online = $o $fritzweb_last_connection = $c endif if ($failed=1) MsgBox("call to fw_cost failed","Hamster Error",0x10|0x0) $online = "error" $connection = "error" endif endif else $online = 0 $connection = "" endif debug(2,"online="+$online+" connection="+$connection) endsub