January 27th, 2000, 09:16 AM
Can someone please tell me what I am doing wrong.
I am trying to rename a file that is currently in use without rebooting.
I can successfully get it to change after I reboot but that is defeating the whole purpose.
Thanks
Thomas
I am running WINNT 4.0 SP4
The code below is just an example
Declare Function MoveFileEx Lib "kernel32" Alias "MoveFileExA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal dwFlags As Long) As Long
Private Const MOVEFILE_REPLACE_EXISTING = &H1
Private Const MOVEFILE_COPY_ALLOWED = &H2
Private Const MOVEFILE_WRITE_THROUGH = &H3
Private Const MOVEFILE_DELAY_UNTIL_REBOOT = &H4
Sub Main()
Dim lresult As Long
ChDrive ("C:")
ChDir ("c:\WINDOWS\SYSTEM32")
'lresult = MoveFileEx("C:\Temp\Iscode\Files\msvbvm60.dll", "C:\WINDOWS\SYSTEM32\msvbvm60.DLL", MOVEFILE_DELAY_UNTIL_REBOOT)
lresult = MoveFileEx("C:\WINDOWS\SYSTEM32\msvbvm60.DLL", "C:\WINDOWS\SYSTEM32\msvbvm60.DLL.old", MOVEFILE_REPLACE_EXISTING Or MOVEFILE_COPY_ALLOWED)
If lresult = 0 Then
MsgBox "Phase 1 Didnt work"
Else
MsgBox "Phase 1 Worked"
End
End If
End Sub
I am trying to rename a file that is currently in use without rebooting.
I can successfully get it to change after I reboot but that is defeating the whole purpose.
Thanks
Thomas
I am running WINNT 4.0 SP4
The code below is just an example
Declare Function MoveFileEx Lib "kernel32" Alias "MoveFileExA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal dwFlags As Long) As Long
Private Const MOVEFILE_REPLACE_EXISTING = &H1
Private Const MOVEFILE_COPY_ALLOWED = &H2
Private Const MOVEFILE_WRITE_THROUGH = &H3
Private Const MOVEFILE_DELAY_UNTIL_REBOOT = &H4
Sub Main()
Dim lresult As Long
ChDrive ("C:")
ChDir ("c:\WINDOWS\SYSTEM32")
'lresult = MoveFileEx("C:\Temp\Iscode\Files\msvbvm60.dll", "C:\WINDOWS\SYSTEM32\msvbvm60.DLL", MOVEFILE_DELAY_UNTIL_REBOOT)
lresult = MoveFileEx("C:\WINDOWS\SYSTEM32\msvbvm60.DLL", "C:\WINDOWS\SYSTEM32\msvbvm60.DLL.old", MOVEFILE_REPLACE_EXISTING Or MOVEFILE_COPY_ALLOWED)
If lresult = 0 Then
MsgBox "Phase 1 Didnt work"
Else
MsgBox "Phase 1 Worked"
End
End If
End Sub