Tyagus Posted July 13, 2006 at 04:09 PM Report #38073 Posted July 13, 2006 at 04:09 PM Este código contém uma série de funções que dão sempre muito jeito. Public Sub MakeDir(DirPath As String) 'Criar directorio On Error GoTo error MkDir DirPath$ Exit Sub error: MsgBox Err.Description, vbExclamation, "Erro" End Sub Public Sub DeleteDir(DirPath As String) 'Apagar um directorio On Error GoTo error RmDir DirPath$ Exit Sub error: MsgBox Err.Description, vbExclamation, "Erro" End Sub Public Sub DelFilesInDir(DirPath As String, DelDir As Boolean) 'Apagar todos os ficheiros de um directorio e (opcional) também apagar o directorio On Error GoTo error Kill DirPath$ & "*.*" If DelDir = True Then RmDir DirPath$ End If Exit Sub error: MsgBox Err.Description, vbExclamation, "Erro" End Sub Public Sub MoveFile(StartPath As String, EndPath As String) 'Mover um ficheiro On Error GoTo error FileCopy StartPath$, EndPath$ Kill StartPath$ Exit Sub error: MsgBox Err.Description, vbExclamation, "Erro" End Sub Public Sub CopyFile(StartPath As String, EndPath As String) 'Copiar um ficheiro On Error GoTo error FileCopy StartPath$, EndPath$ Exit Sub error: MsgBox Err.Description, vbExclamation, "Erro" End Sub Public Sub DeleteFile(FilePath As String) 'Apagar um ficheiro On Error GoTo error Kill FilePath$ Exit Sub error: MsgBox Err.Description, vbExclamation, "Erro" End Sub Public Sub ExecuteFile(FilePath As String) 'Executar um ficheiro On Error GoTo error ret = Shell("rundll32.exe url.dll,FileProtocolHandler " & (FilePath)) Exit Sub error: MsgBox Err.Description, vbExclamation, "Erro" End Sub Em caso de dúvidas contactem. 😄
NuGuN Posted July 13, 2006 at 04:46 PM Report #38078 Posted July 13, 2006 at 04:46 PM Uma boa ideia seria fazeres uma Class com todas essa funções 😄 Um perguntinha 😄 Podes esplicar esta linha ret = Shell("rundll32.exe url.dll,FileProtocolHandler " & (FilePath)) eu sei que Shell é para abriri um ficheiro ou programa, só não percebo para que utilizas "rundll32.exe url.dll,FileProtocolHandler " e "FileProtocolHandler" é alguma variavel que se tem de criasr ? cumps
Tyagus Posted July 13, 2006 at 05:08 PM Author Report #38088 Posted July 13, 2006 at 05:08 PM O rundll32.exe é um processo que executa DLL's e coloca as bibliotecas em memória, de forma a serem usadas de forma mais eficiente pelas aplicações. Quanto ao url.dll (ou comon a Microsoft lhe chama - Internet Shortcut Shell Extension Library) é usado pelo Windows e por Windows Applications quando são criados atalhos para páginas web (e acho que não só, ou seja, para todo o tipo de atalhos do Windows). O FileProtocolHandler é uma "variável" do VB6. Espero que a ajuda tenha sido útil. 😄
NuGuN Posted July 13, 2006 at 06:57 PM Report #38113 Posted July 13, 2006 at 06:57 PM esta bem esplicado, eu é que não fiz a pergunta correcta ? Mas tive a ver melhor e ja percebi. Eu não estava a perceber porque estavas a trabalhar com esse código(ret = Shell("rundll32.exe url.dll,FileProtocolHandler " & (FilePath))) e não apenas com ret = Shell(FilePath). Mas ja percebi.. se tiver apenas ret = Shell(FilePath) só dá para carregar executaveis e ficheiros desse tipo, e se quisermos carregar p exemplo um .txt dá erro... Só continu com uma duvida... a variavel FileProtocolHandler serve para a aplicação que for aberta, ficar com o mesmo handle que a aplicação que a carregou certo?? cumps
Tyagus Posted July 14, 2006 at 09:39 AM Author Report #38213 Posted July 14, 2006 at 09:39 AM Em relação a isso eu não tenho a certeza absoluta, mas acho que sim... 😄
NuGuN Posted July 14, 2006 at 12:09 PM Report #38229 Posted July 14, 2006 at 12:09 PM Tyagus dás-me autirização para eu fazer um pequeno tutorial com essas funções que tu fizeste??? cumps
Tyagus Posted July 17, 2006 at 09:06 AM Author Report #38581 Posted July 17, 2006 at 09:06 AM Claro que sim... É algo que eu acho que iria completar a função e que iria ajudar a que esta função tivesse mais utilidade.
jtiagodias Posted October 12, 2008 at 03:31 PM Report #217450 Posted October 12, 2008 at 03:31 PM gostava muito de ver ese tut... queria fazzer umas coisas para o qual dava jeito utilzar algumas dessas funções. Vão mesmo publicar?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now