Visual Basic - Error 76. Error de acceso a ruta

Life is soft - evento anual de software empresarial
 
Vista:

Error 76. Error de acceso a ruta

Publicado por Roberto (16 intervenciones) el 05/02/2009 22:02:44
Muy buenas les cuento mi problema. Estoy intentando copiar un archivo dll que tengo en la carpeta de mi programa al system 32. La cosa es que cuando lo intento me sale ese error y no consigo solucionarlo. El codigo empleado es el siguiente:

MiArchivo = App.Path & "MSDBRPTR.DLL"
FileCopy MiArchivo, "C:WindowsSystem32"

He probado a copiarlo en otra carpeta cualquiera por si no me dejara por ser system32 pero aun asi no hay manera. El archivo no esta marcado como solo lectura ni nada por el estilo.
A ver si alguien sabe como solucionar esto pq no lo entiendo, muchas gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Error 76. Error de acceso a ruta

Publicado por P3L30N2009 (699 intervenciones) el 05/02/2009 23:11:21
Parece que tienes un problema con el FileCopy, te propongo otra solución:

--- código:
Dim FSO As New FileSystemObject
Dim File As File
Set File = FSO.GetFile(App.Path & "\MSDBRPTR.DLL")
File.Copy ("C:\Windows\System32\MSDBRPTR.DLL")
--- fin del código:

Tienes que marcar la referencia a Microsoft Scripting Runtime

A continuación, como te indiqué antes, tienes que registrar la librería, sino no vale de nada.

Y si te funciona, espero que lo indiques y si no también!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Error 76. Error de acceso a ruta

Publicado por Roberto (16 intervenciones) el 06/02/2009 00:28:27
Ahora parece que si copia bien, ya que al hacerlo a una carpeta de destino de prueba lo hace sin problema, sin embargo al intentar hacerlo a system32 me da error, permiso denegado...
A ver si esto se puede solucionar.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Error 76. Error de acceso a ruta

Publicado por P3L30N2009 (699 intervenciones) el 06/02/2009 12:55:39
Revisa las propiedades del directorio System32, es posible que sea de solo lectura, oculto o esté protegido.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Error 76. Error de acceso a ruta

Publicado por Roberto (16 intervenciones) el 06/02/2009 15:53:38
Bueno el problema venia porque la Dll que queria mover la usaba el propio VB, asi que fue crear el .exe y al cerrar el vb ya me dejaba....

La cosa es q ahora tengo otra duda, respecto a un tema de imprimir que comente en un hilo anterior, aver al hacer click en el boton de imprimir llamo a un modulo .bas el cual contiene el siguiente codigo:

Option Explicit


'Constantes
Const CCHDEVICENAME = 32
Const CCHFORMNAME = 32
Const DM_DUPLEX = &H1000&
Const DM_ORIENTATION = &H1&
Const PD_PRINTSETUP = &H40
Const GMEM_MOVEABLE = &H2
Const GMEM_ZEROINIT = &H40
Const PD_DISABLEPRINTTOFILE = &H80000

'Funciones API
Private Declare Function PrintDialog Lib "comdlg32.dll" Alias "PrintDlgA" ( _
pPrintdlg As PRINTDLG_TYPE) As Long
Private Declare Function PAGESETUPDLG Lib "comdlg32.dll" Alias "PageSetupDlgA" ( _
pPagesetupdlg As PAGESETUPDLG) As Long
Private Declare Function GlobalLock Lib "kernel32" ( _
ByVal hMem As Long) As Long
Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalAlloc Lib "kernel32" ( _
ByVal wFlags As Long, _
ByVal dwBytes As Long) As Long
Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
hpvDest As Any, _
hpvSource As Any, _
ByVal cbCopy As Long)

' UDT
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Type PAGESETUPDLG
lStructSize As Long
hwndOwner As Long
hDevMode As Long
hDevNames As Long
Flags As Long
ptPaperSize As POINTAPI
rtMinMargin As RECT
rtMargin As RECT
hInstance As Long
lCustData As Long
lpfnPageSetupHook As Long
lpfnPagePaintHook As Long
lpPageSetupTemplateName As String
hPageSetupTemplate As Long
End Type


Private Type PRINTDLG_TYPE
lStructSize As Long
hwndOwner As Long
hDevMode As Long
hDevNames As Long
hDC As Long
Flags As Long
nFromPage As Integer
nToPage As Integer
nMinPage As Integer
nMaxPage As Integer
nCopies As Integer
hInstance As Long
lCustData As Long
lpfnPrintHook As Long
lpfnSetupHook As Long
lpPrintTemplateName As String
lpSetupTemplateName As String
hPrintTemplate As Long
hSetupTemplate As Long
End Type
Private Type DEVNAMES_TYPE
wDriverOffset As Integer
wDeviceOffset As Integer
wOutputOffset As Integer
wDefault As Integer
extra As String * 100
End Type

Private Type DEVMODE_TYPE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type

'Fin de declaraciones

'----------------------------------

'El_Formulario.hwnd

'Para el Common diálogo de imprimir ( pasar el formulario como parámetro )
'---------------------------------------------------------
Public Sub Show_Printer(El_Formulario As Form, Optional Flags As Long)

On Error GoTo ErrSub

Dim t_Printer As PRINTDLG_TYPE
Dim DevMode As DEVMODE_TYPE
Dim DevName As DEVNAMES_TYPE

Dim lpDevMode As Long, lpDevName As Long
Dim bReturn As Integer
Dim objPrinter As Printer, NewPrinterName As String

With t_Printer
.lStructSize = Len(t_Printer)
.hwndOwner = El_Formulario.hwnd
.Flags = Flags
End With

On Error Resume Next

DevMode.dmDeviceName = Printer.DeviceName
DevMode.dmSize = Len(DevMode)
DevMode.dmFields = DM_ORIENTATION Or DM_DUPLEX
DevMode.dmPaperWidth = Printer.Width
DevMode.dmOrientation = Printer.Orientation
DevMode.dmPaperSize = Printer.PaperSize
DevMode.dmDuplex = Printer.Duplex

On Error GoTo 0

t_Printer.hDevMode = GlobalAlloc(GMEM_MOVEABLE Or GMEM_ZEROINIT, Len(DevMode))
lpDevMode = GlobalLock(t_Printer.hDevMode)

If lpDevMode > 0 Then
CopyMemory ByVal lpDevMode, DevMode, Len(DevMode)
bReturn = GlobalUnlock(t_Printer.hDevMode)
End If


With DevName
.wDriverOffset = 8
.wDeviceOffset = .wDriverOffset + 1 + Len(Printer.DriverName)
.wOutputOffset = .wDeviceOffset + 1 + Len(Printer.Port)
.wDefault = 0
End With

With Printer
DevName.extra = .DriverName & Chr(0) & .DeviceName & Chr(0) & .Port & Chr(0)
End With

t_Printer.hDevNames = GlobalAlloc(GMEM_MOVEABLE Or GMEM_ZEROINIT, Len(DevName))
lpDevName = GlobalLock(t_Printer.hDevNames)

If lpDevName > 0 Then
CopyMemory ByVal lpDevName, DevName, Len(DevName)
bReturn = GlobalUnlock(lpDevName)
End If


If PrintDialog(t_Printer) <> 0 Then '****** AQUI MIRA SI SE LE DA O NO A CANCELAR, SI ES CANCELAR SALE DEL IF*********
lpDevName = GlobalLock(t_Printer.hDevNames)
CopyMemory DevName, ByVal lpDevName, 45
bReturn = GlobalUnlock(lpDevName)
GlobalFree t_Printer.hDevNames


lpDevMode = GlobalLock(t_Printer.hDevMode)
CopyMemory DevMode, ByVal lpDevMode, Len(DevMode)
bReturn = GlobalUnlock(t_Printer.hDevMode)
GlobalFree t_Printer.hDevMode
NewPrinterName = UCase$(Left(DevMode.dmDeviceName, _
InStr(DevMode.dmDeviceName, Chr$(0)) - 1))

If Printer.DeviceName <> NewPrinterName Then
For Each objPrinter In Printers
If UCase$(objPrinter.DeviceName) = NewPrinterName Then
Set Printer = objPrinter
End If
Next
End If

On Error Resume Next

With Printer
.PaperSize = DevMode.dmPaperSize
.PrintQuality = DevMode.dmPrintQuality
.ColorMode = DevMode.dmColor
.PaperBin = DevMode.dmDefaultSource
.Copies = DevMode.dmCopies
.Duplex = DevMode.dmDuplex
.Orientation = DevMode.dmOrientation
End With
On Error GoTo 0
DataReport1.PrintReport
End If

Exit Sub

ErrSub:

If Err.Number = 484 Then
MsgBox "Error al obtener información de la impresora." & _
"Asegurarse que está instalada correctamente.", vbCritical
End If

End Sub

Como veis he metido la orden printreport del reporte al final de haber elegido la impresora, la pregunta es, esta bien colocado en esa posicion? En mi casa funciona pero donde lo tengo q ejecutar no...
Muchas gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar