INIBIR PERGUNTA E TELA DE COPIANDO DO WINDOWS
Senhores,
tenho uma programa que faz backup. até aà tudo bem funciona bem. só que tem duas coisas que até agora não consegui fazer funcionar:
1 - quando não existe uma pasta o programa dá a mensagem de pasta não existente. deseja criar?
Neste caso deveria inibir essa pergunta e criar já direto essa pasta.
2 - inibir a tela de copiando do windows. Não queria que essa tela aparecesse para o usuário.
Veja o código que uso:
Public Declare Function SHFileOperation Lib _
[Ô]shell32.dll[Ô] Alias [Ô]SHFileOperationA[Ô] _
(lpFileOp As Any) As Long
Public Declare Sub SHFreeNameMappings Lib _
[Ô]shell32.dll[Ô] (ByVal hNameMappings As Long)
Public Declare Sub CopyMemory Lib [Ô]KERNEL32[Ô] _
Alias [Ô]RtlMoveMemory[Ô] (hpvDest As Any, hpvSource _
As Any, ByVal cbCopy As Long)
Public Type SHFILEOPSTRUCT
hwnd As Long
wFunc As FO_Functions
pFrom As String
pTo As String
fFlags As FOF_Flags
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String [ô]only used if FOF_SIMPLEPROGRESS
End Type
Public Enum FO_Functions
FO_MOVE = &H1
FO_COPY = &H2
FO_DELETE = &H3
FO_RENAME = &H4
End Enum
Public Enum FOF_Flags
FOF_MULTIDESTFILES = &H1
FOF_CONFIRMMOUSE = &H2
FOF_SILENT = &H4
FOF_RENAMEONCOLLISION = &H8
FOF_NOCONFIRMATION = &H10
FOF_WANTMAPPINGHANDLE = &H20
FOF_ALLOWUNDO = &H40
FOF_FILESONLY = &H80
FOF_SIMPLEPROGRESS = &H100
FOF_NOCONFIRMMKDIR = &H200
FOF_NOERRORUI = &H400
FOF_NOCOPYSECURITYATTRIBS = &H800
FOF_NORECURSION = &H1000
FOF_NO_CONNECTED_ELEMENTS = &H2000
FOF_WANTNUKEWARNING = &H4000
End Enum
Public Type SHNAMEMAPPING
pszOldPath As String
pszNewPath As String
cchOldPath As Long
cchNewPath As Long
End Type
Public Function SHFileOP(ByRef lpFileOp As SHFILEOPSTRUCT) As Long
Dim result As Long
Dim lenFileop As Long
Dim foBuf() As Byte
lenFileop = LenB(lpFileOp)
ReDim foBuf(1 To lenFileop) [ô]the size of the structure.
Call CopyMemory(foBuf(1), lpFileOp, lenFileop)
Call CopyMemory(foBuf(19), foBuf(21), 12)
result = SHFileOperation(foBuf(1))
SHFileOP = result
End Function
Obrigado
tenho uma programa que faz backup. até aà tudo bem funciona bem. só que tem duas coisas que até agora não consegui fazer funcionar:
1 - quando não existe uma pasta o programa dá a mensagem de pasta não existente. deseja criar?
Neste caso deveria inibir essa pergunta e criar já direto essa pasta.
2 - inibir a tela de copiando do windows. Não queria que essa tela aparecesse para o usuário.
Veja o código que uso:
Public Declare Function SHFileOperation Lib _
[Ô]shell32.dll[Ô] Alias [Ô]SHFileOperationA[Ô] _
(lpFileOp As Any) As Long
Public Declare Sub SHFreeNameMappings Lib _
[Ô]shell32.dll[Ô] (ByVal hNameMappings As Long)
Public Declare Sub CopyMemory Lib [Ô]KERNEL32[Ô] _
Alias [Ô]RtlMoveMemory[Ô] (hpvDest As Any, hpvSource _
As Any, ByVal cbCopy As Long)
Public Type SHFILEOPSTRUCT
hwnd As Long
wFunc As FO_Functions
pFrom As String
pTo As String
fFlags As FOF_Flags
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String [ô]only used if FOF_SIMPLEPROGRESS
End Type
Public Enum FO_Functions
FO_MOVE = &H1
FO_COPY = &H2
FO_DELETE = &H3
FO_RENAME = &H4
End Enum
Public Enum FOF_Flags
FOF_MULTIDESTFILES = &H1
FOF_CONFIRMMOUSE = &H2
FOF_SILENT = &H4
FOF_RENAMEONCOLLISION = &H8
FOF_NOCONFIRMATION = &H10
FOF_WANTMAPPINGHANDLE = &H20
FOF_ALLOWUNDO = &H40
FOF_FILESONLY = &H80
FOF_SIMPLEPROGRESS = &H100
FOF_NOCONFIRMMKDIR = &H200
FOF_NOERRORUI = &H400
FOF_NOCOPYSECURITYATTRIBS = &H800
FOF_NORECURSION = &H1000
FOF_NO_CONNECTED_ELEMENTS = &H2000
FOF_WANTNUKEWARNING = &H4000
End Enum
Public Type SHNAMEMAPPING
pszOldPath As String
pszNewPath As String
cchOldPath As Long
cchNewPath As Long
End Type
Public Function SHFileOP(ByRef lpFileOp As SHFILEOPSTRUCT) As Long
Dim result As Long
Dim lenFileop As Long
Dim foBuf() As Byte
lenFileop = LenB(lpFileOp)
ReDim foBuf(1 To lenFileop) [ô]the size of the structure.
Call CopyMemory(foBuf(1), lpFileOp, lenFileop)
Call CopyMemory(foBuf(19), foBuf(21), 12)
result = SHFileOperation(foBuf(1))
SHFileOP = result
End Function
Obrigado
A resposta ja esta com voce
FOF_SILENT = &H4
FOF_RENAMEONCOLLISION = &H8
FOF_NOCONFIRMATION = &H10
MESMO Jà COM ESSAS OPÇÕES A TELA E A PERGUNTA CONTINUAM APARECENDO
FOF_SILENT = &H4
FOF_RENAMEONCOLLISION = &H8
FOF_NOCONFIRMATION = &H10
PQ SERÃ?
FOF_SILENT = &H4
FOF_RENAMEONCOLLISION = &H8
FOF_NOCONFIRMATION = &H10
PQ SERÃ?
fFlags foi setado com que valores ?
Voce usou OR ou AND entre as ligacoes das flags ?
Voce usou OR ou AND entre as ligacoes das flags ?
Public Function CopiarArquivo(Src As String, Dest As String, Optional NoConfirm As Boolean = True) As Boolean
[ô]Copia um arquivo usando uma janela do Windows para demonstrar o status
Dim WinType_SFO As SHFILEOPSTRUCT
Dim lRet As Long
Dim lFlags As Long
lFlags = FOF_ALLOWUNDO
If NoConfirm Then lFlags = lFlags & FOF_NOCONFIRMATION
With WinType_SFO
.wFunc = FO_COPY
.pFrom = Src
.pTo = Dest
.fFlags = lFlags
End With
lRet = SHFileOperation(WinType_SFO)
CopiarArquivo = (lRet = 0)
End Function
Tópico encerrado , respostas não são mais permitidas