• 0

(VB) Copying file which is in use


Question

I'm trying to test if my SAM file (C:\Windows\System32\Config\SAM) protects my paswords good enough trough various methods. :ninja:

I want to copy the sam file on to a USB-Stick, to make sure I can put it back when I **** it up :cool: .

Does anyone of you know the API-call to copy a file which is in use a.t.m., or do you have an other way to do this?

I found something on the internet... but that didn't work for me.

Maybe because I'm not using it the right way.

The API/Function/Etc I used was this:

----------------------------------------------------------------------

Private Declare Function SHFileOperation Lib "shell32.dll" _

(lpFileOp As SHFILEOP) As Long

Type SHFILEOP

hwnd As Long

wFunc As Long

pFrom As String

pTo As String

fFlags As Integer

fAnyOperationsAborted As Long

hNameMappings As Long

lpszProgressTitle As String

End Type

Public Const FO_MOVE = &H1

Public Const FO_COPY = &H2

Public Const FO_DELETE = &H3

Public Const FOF_SILENT = &H4

Public Const FOF_ALLOWUNDO = &H40

Public Const FOF_NOCONFIRMATION = &H10

Public Const FOF_NOCONFIRMMKDIR = &H200

Public Sub FileCopyEx(lngHWnd As Long, strFromPath As String, strToPath As String)

Dim ShellOp As SHFILEOP

Dim lngRet As Long

Dim flg As Long

flg = FOF_SILENT + FOF_NOCONFIRMATION + FOF_NOCONFIRMMKDIR

With ShellOp

.hwnd = lngHWnd

.wFunc = FO_COPY

.pFrom = strFromPath

.pTo = strToPath

.fFlags = flg

End With

lngRet = SHFileOperation(ShellOp)

End Sub

----------------------------------------------------------------------

However, that doesn't work :huh: . Can anyone tell me what to do?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.