Module Module1
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub Pause(ByVal sec As Single)
Dim t As Single
t = Timer + sec
If t >= 86400 Then t = 0 'evita il midnight-bug
Do
'DoEvents() 'permette di agire sui controlli
'MsgBox("sto aspettando"
Sleep(500)
Loop While Timer < t
End Sub
Sub Main()
Dim NomeFile, NomeFile1 As String
Dim Peso1, Peso2 As Long
Dim fs As System.IO.FileStream
Dim fileInUse As Boolean = True
NomeFile = "C:\TemporaryUpload\" + Command()
'MsgBox(NomeFile)
Do
Do
Peso1 = FileLen(NomeFile)
Pause(15)
Peso2 = FileLen(NomeFile)
If Peso2 = Peso1 Then
'MsgBox(Peso2)
Exit Do
End If
Loop
Try
fs = System.IO.File.Open(NomeFile, IO.FileMode.Open, IO.FileAccess.Write, IO.FileShare.None)
fileInUse = False
'MsgBox("chiuso"
fs.Close()
Catch ex As Exception
fileInUse = True
'MsgBox("aperto"
End Try
Loop While fileInUse = True
'MsgBox("caiser"
' nome che avrà il file renderizzato come da formato MAM
NomeFile1 = DateString() & "_" & CInt(Rnd() * 100) & "_" & TimeString()
' sostituisco nel nome il carattere / e . con il carattere _ e tolgo gli spazi tra i caratteri del nome
NomeFile1 = Replace(NomeFile1, "-", "_"
NomeFile1 = Replace(NomeFile1, ":", "_"
NomeFile1 = "C:\TemporaryUpload\" + NomeFile1 + ".mov"
'MsgBox(NomeFile1)
Rename(NomeFile, NomeFile1)
'Shell("render_mov.exe " + NomeFile1)
System.Diagnostics.Process.Start("C:\Programmi\MAM_Watch_folder\RenderBat.exe " + NomeFile1)
End Sub
Application.Exit()
End Module