Home All Groups Group Topic Archive Search About
Author
28 Aug 2006 11:40 AM
sgr
Hello.

I'm trying to do a program that delete some files and registry entries, Is
there any way to delete the files that "are in use".

Thanks in advance.

Author
28 Aug 2006 12:41 PM
Herfried K. Wagner [MVP]
"sgr" <s**@discussions.microsoft.com> schrieb:
> I'm trying to do a program that delete some files and registry entries, Is
> there any way to delete the files that "are in use".

Check out the "Remarks" section of 'MoveFileEx'' documentation:

File Systems -- 'MoveFileEx'
<URL:http://msdn.microsoft.com/library/en-us/fileio/fs/movefileex.asp>

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
28 Aug 2006 10:51 PM
Herfried K. Wagner [MVP]
Addendum:

How To Move Files That Are Currently in Use
<URL:http://support.microsoft.com/?scid=kb;EN-US;140570>

\\\
Private Declare Auto Function MoveFileEx Lib "kernel32.dll" ( _
    ByVal lpExistingFileName As String, _
    ByVal lpNewFileName As String, _
    ByVal dwFlags As Int32 _
) As Boolean

Private Const MOVEFILE_DELAY_UNTIL_REBOOT As Int32 = &H4
....
Dim Success As Boolean = _
    MoveFileEx( _
        <file name>, _
        vbNullString, _
        MOVEFILE_DELAY_UNTIL_REBOOT _
    )
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
30 Aug 2006 7:52 AM
sgr
Thanks for all.

It runs ok, but I need a way to remove a registry entry and i haven`t
permissions in the key.
I 'm administrator of the computer. Is there any way in VB .NET to change
the permissions?

Thanks for all.

Show quoteHide quote
"Herfried K. Wagner [MVP]" wrote:

> Addendum:
>
> How To Move Files That Are Currently in Use
> <URL:http://support.microsoft.com/?scid=kb;EN-US;140570>
>
> \\\
> Private Declare Auto Function MoveFileEx Lib "kernel32.dll" ( _
>     ByVal lpExistingFileName As String, _
>     ByVal lpNewFileName As String, _
>     ByVal dwFlags As Int32 _
> ) As Boolean
>
> Private Const MOVEFILE_DELAY_UNTIL_REBOOT As Int32 = &H4
> ....
> Dim Success As Boolean = _
>     MoveFileEx( _
>         <file name>, _
>         vbNullString, _
>         MOVEFILE_DELAY_UNTIL_REBOOT _
>     )
> ///
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
>