Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do any one know how to use the MoveFileEx function 1

Status
Not open for further replies.

devinci

MIS
Feb 15, 2002
46
0
0
CA
I'm trying to delete a file when the computer boots up.

This is the code I have...

Declare Function MoveFileEx Lib "kernel32" Alias "MoveFileExA" ( _
ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal dwFlags As Long _
) As Long

MoveFileEx(szDstFile, Null, MOVEFILE_DELAY_UNTIL_REBOOT)

I've been searching for two days...And nothing...I can't find nothing

Thanks...
 
I suppose you want to replace system files? Is your OS WinNT? Since the API is meant for replacing files maybe assigning NULL to lpNewFileName is not allowed? Why not replace the suffice with .old in lpNewFileName?

Herman [pc]
 
yes, my OS is Windows 2000,

Is that every where that I search they placed to Null value is the command...I'm really confuse...
 
The examples that you have seen have either been for C/C++, or badly 'translated' into VB. The following should help out, with the one minor change emboldened:
[tt]
Declare Function MoveFileEx Lib "kernel32" Alias "MoveFileExA" ( _
ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal dwFlags As Long _
) As Long

Private Const MOVEFILE_DELAY_UNTIL_REBOOT = &H4

MoveFileEx(szDstFile, vbNullString, MOVEFILE_DELAY_UNTIL_REBOOT)
 
Thank you very much Strongm....it works like a charm...

Thanks again...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top