Gelöst - WebDAV Code PB 5.00 Korrektur

Für allgemeine Fragen zur Programmierung mit PureBasic.
_v4
Beiträge: 26
Registriert: 16.11.2012 13:36

Gelöst - WebDAV Code PB 5.00 Korrektur

Beitrag von _v4 »

Hallo,

wollte mit PB 5.00 auf ein WebDAV eine Datei kopieren. Hab hierzu folgenden Code gefunden:
http://www.purebasic.fr/german/viewtopi ... 37#p271237

Leider kriege ich in Zeile 153 eine Fehlermeldung, das ein String erwartet wird.

Vielen Dank schonmal für die Hilfe!
Zuletzt geändert von _v4 am 11.12.2012 13:47, insgesamt 1-mal geändert.
Benutzeravatar
Falko
Admin
Beiträge: 3535
Registriert: 29.08.2004 11:27
Computerausstattung: PC: MSI-Z590-GC; 32GB-DDR4, ICore9; 2TB M2 + 2x3TB-SATA2 HDD; Intel ICore9 @ 3600MHZ (Win11 Pro. 64-Bit),
Acer Aspire E15 (Win11 Home X64). Purebasic LTS 6.11b1
HP255G8 Notebook @AMD Ryzen 5 5500U with Radeon Graphics 2.10 GHz 3.4GHz, 32GB_RAM, 3TB_SSD (Win11 Pro 64-Bit)
Kontaktdaten:

Re: Code funktioniert leider so nicht

Beitrag von Falko »

Vielleicht hilft dir beim Pointer *buffer Peeks(*buffer)
weiter.
Aber warum machst du hier einen neuen Thread auf?

Gruß Falko
Bild
Win11 Pro 64-Bit, PB_6.11b1
_v4
Beiträge: 26
Registriert: 16.11.2012 13:36

Re: Code funktioniert leider so nicht

Beitrag von _v4 »

Hallo Falko,

danke für die schnelle Antwort. Leider hilfts mir nicht weiter und wollte in dem anderen Forum nicht mit Verständnisfragen aufkreuzen. Hatte erhofft, dass das nur ne Kleinigkeit ist, finde aber die Lösung nicht selber. Bin auch leider überhaupt nicht fit was Pointer angeht, deshalb dachte ich, ich schreibe hier ins Anfängerforum.
Benutzeravatar
Falko
Admin
Beiträge: 3535
Registriert: 29.08.2004 11:27
Computerausstattung: PC: MSI-Z590-GC; 32GB-DDR4, ICore9; 2TB M2 + 2x3TB-SATA2 HDD; Intel ICore9 @ 3600MHZ (Win11 Pro. 64-Bit),
Acer Aspire E15 (Win11 Home X64). Purebasic LTS 6.11b1
HP255G8 Notebook @AMD Ryzen 5 5500U with Radeon Graphics 2.10 GHz 3.4GHz, 32GB_RAM, 3TB_SSD (Win11 Pro 64-Bit)
Kontaktdaten:

Re: Code funktioniert leider so nicht

Beitrag von Falko »

Okay,
dann versuche ich das mal hier weiter. Ich kann aber den Code nicht testen, da mir
diese Exe fehlt. Vielleicht hilft dir das so weiter.

Code: Alles auswählen

Enumeration 0 ; Error Messages
  #PURECOPY_OK
 
  #PURECOPY_USERCANCELED
 
  #PURECOPY_ERROR_NOTFOUND
  #PURECOPY_ERROR_NOREADFILE
  #PURECOPY_ERROR_NOWRITEFILE
  #PURECOPY_ERROR_READDENIED
  #PURECOPY_ERROR_WRITEDENIED
  #PURECOPY_ERROR_DIRECTORYDENIED
  #PURECOPY_ERROR_DIRECTORIESMATCH
EndEnumeration


Enumeration 0 ; Compare routines
  #PURECOPY_COMPARE_NONE
 
  #PURECOPY_COMPARE_DATE ; Simple filedate compare, recommend, fastest
  #PURECOPY_COMPARE_CRC ; Memory based CRC32 checksum compare
  #PURECOPY_COMPARE_SIZE ; Check the file sizes
 
  #PURECOPY_COMPARE_EXISTS ; Continue, if destination file already exists
  #PURECOPY_COMPARE_ASKCALLBACK ; Ask the Compare Callback for overwriting
 
  ; If compare routine not specified, files will always be overwritten
EndEnumeration


; Set Data Modes
#PURECOPY_PROPERTY_CREATED = 1
#PURECOPY_PROPERTY_ACCESSED = 2
#PURECOPY_PROPERTY_MODIFIED = 4
#PURECOPY_PROPERTY_ATTRIBUTES = 8


Enumeration
  #W_Main
EndEnumeration

Enumeration
  #M_Main
EndEnumeration

Enumeration
  #Event_ImageInput
  #Event_ImageOutput
 
  #Event_Start
 
  #Event_SubDirectories
  #Event_SetFilePropertiesCreated
  #Event_SetFilePropertiesAccessed
  #Event_SetFilePropertiesModified
  #Event_SetFilePropertiesAttributes
  #Event_CompareRoutine
  #Event_WaitOnError
  #Event_SimultaneousTransfer
 
  #Event_Website
 
  #Event_ShowWindow
  #Event_End
EndEnumeration

Enumeration
  #I_Input
  #I_Output
  #I_SystrayMain
EndEnumeration


Enumeration
  #Param_Default
  #Param_Directory
  #Param_Unknown
EndEnumeration



Define InputFilepath.s = ""
Global InputFiles.s = ""
Global OutputFilepath.s = ""
Define OutputFilepathTemp.s = ""

Define FilesCount.l = 0
Define FileIndex.l

Define SystrayMain.l

Procedure DrawFilepathIcon(Image, Filepath.s, Parameter)
  Define shInfo.SHFILEINFO
 
  Select Parameter
  Case #Param_Unknown
    ExtractIconEx_("shell32.dll", 175, @shInfo\hIcon, 0, 1)
   
  Case #Param_Directory
    ExtractIconEx_("shell32.dll", 54, @shInfo\hIcon, 0, 1)
 
  Case #Param_Default
    If FileSize(Filepath) = -2
      ExtractIconEx_("shell32.dll", 3, @shInfo\hIcon, 0, 1)
    Else
      SHGetFileInfo_(Filepath, #FILE_ATTRIBUTE_NORMAL, @shInfo, SizeOf(shInfo), #SHGFI_USEFILEATTRIBUTES | #SHGFI_ICON | #SHGFI_LARGEICON)
     
      If shInfo\hIcon = 0
        ExtractIconEx_(Filepath, 0, @shInfo\hIcon, 0, 1)
      EndIf
     
      If shInfo\hIcon = 0
        ExtractIconEx_("shell32.dll", 0, @shInfo\hIcon, 0, 1)
      EndIf
    EndIf
  EndSelect
 
  CreateImage(Image, 32, 32)
  If StartDrawing(ImageOutput(Image))
    Box(0, 0, 32, 32, GetSysColor_(#COLOR_BTNFACE))
   
    If shInfo\hIcon
      DrawImage(shInfo\hIcon, 0, 0)
    EndIf
    StopDrawing()
  EndIf
 
 
  If shInfo\hIcon
    DestroyIcon_(shInfo\hIcon)
  EndIf
EndProcedure


Procedure.s _ShortcutTarget(ShortcutFile.s)
  Define Result.s = ""
 
  If Right(LCase(ShortcutFile), 4) <> ".lnk"
    ProcedureReturn ShortcutFile
  EndIf
 
  CoInitialize_(0)
 
  Define ShellLink.IShellLinkA
  Define LinkFile.IPersistFile
 
  If CoCreateInstance_(?CLSID_ShellLink, 0, 1, ?IID_IShellLink, @ShellLink) = #S_OK
    If ShellLink\QueryInterface(?IID_IPersistFile, @LinkFile) = #S_OK
      Define *buffer = AllocateMemory(1024)
     
      If *buffer
        MultiByteToWideChar_(#CP_ACP, 0, @ShortcutFile, -1, *buffer, 1024)
       
        If LinkFile\Load(PeekS(*buffer), 0) = #S_OK
          If ShellLink\Resolve(0, 1) = #S_OK
            RtlZeroMemory_(*buffer, 1024)
            ShellLink\GetPath(PeekS(*buffer), 1024, 0, 0)
            Result = PeekS(*buffer)
          EndIf
        EndIf
       
        FreeMemory(*buffer)
      EndIf
     
      LinkFile\Release()
    EndIf
   
    ShellLink\Release()
  EndIf
 
  CoUninitialize_()
 
  ProcedureReturn Result
 
 
  DataSection
  CLSID_ShellLink:
    Data.l $00021401
    Data.w $0000,$0000     
    Data.b $C0,$00,$00,$00,$00,$00,$00,$46
   
  IID_IShellLink:
    Data.l $000214EE
    Data.w $0000,$0000
    Data.b $C0,$00,$00,$00,$00,$00,$00,$46
   
  IID_IPersistFile:
    Data.l $0000010b
    Data.w $0000,$0000
    Data.b $C0,$00,$00,$00,$00,$00,$00,$46
  EndDataSection
EndProcedure



Procedure StartPureCopy()
  Protected File = CreateFile(#PB_Any, GetTemporaryDirectory() + "~purecopy.exe")
 
  If File
    WriteData(File, ?PURECOPY_INCLUDEEXECUTABLE1, ?PURECOPY_INCLUDEEXECUTABLE2 - ?PURECOPY_INCLUDEEXECUTABLE1)
    CloseFile(File)
   
    Protected Parameter.s = ""
   
    Parameter + InputFiles + Chr(1)
    Parameter + OutputFilepath + Chr(1)
    Parameter + Str(GetGadgetState(#Event_SubDirectories)) + Chr(1)
    Parameter + Str(GetGadgetState(#Event_SetFilePropertiesCreated) * #PURECOPY_PROPERTY_CREATED + GetGadgetState(#Event_SetFilePropertiesAccessed) * #PURECOPY_PROPERTY_ACCESSED + GetGadgetState(#Event_SetFilePropertiesModified) * #PURECOPY_PROPERTY_MODIFIED + GetGadgetState(#Event_SetFilePropertiesAttributes) * #PURECOPY_PROPERTY_ATTRIBUTES) + Chr(1)
    Parameter + Str(GetGadgetState(#Event_CompareRoutine)) + Chr(1)
    Parameter + Str(GetGadgetState(#Event_WaitOnError)) + Chr(1)
    Parameter + Str(GetGadgetState(#Event_SimultaneousTransfer))
   
    RunProgram(GetTemporaryDirectory() + "~purecopy.exe", Parameter, GetPathPart(ProgramFilename()))
  EndIf
EndProcedure







DrawFilepathIcon(#I_Input, "", #Param_Unknown)
DrawFilepathIcon(#I_Output, "", #Param_Unknown)



OpenWindow(#W_Main, 0, 0, 250, 210, "PureCopy", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
StickyWindow(#W_Main, 1)

ImageGadget(#Event_ImageInput, 5, 8, 32, 32, ImageID(#I_Input))
  EnableGadgetDrop(#Event_ImageInput, #PB_Drop_Files, #PB_Drag_Copy | #PB_Drag_Move | #PB_Drag_Link)
 
ButtonGadget(#Event_Start, 50, 5, 150, 40, "> > PureCopy > >")
  DisableGadget(#Event_Start, 1)
 
ImageGadget(#Event_ImageOutput, 210, 8, 32, 32, ImageID(#I_Output))
  EnableGadgetDrop(#Event_ImageOutput, #PB_Drop_Files, #PB_Drag_Copy | #PB_Drag_Move | #PB_Drag_Link)


Frame3DGadget(#PB_Any, 10, 50, 110, 90, "Options")
  CheckBoxGadget(#Event_SubDirectories, 20, 70, 90, 20, "Subdirectories")
    SetGadgetState(#Event_SubDirectories, 1)
  CheckBoxGadget(#Event_WaitOnError, 20, 90, 90, 20, "Wait on error")
  CheckBoxGadget(#Event_SimultaneousTransfer, 20, 110, 90, 20, "Simultaneous")
    SetGadgetState(#Event_SimultaneousTransfer, 1)
   
Frame3DGadget(#PB_Any, 10, 150, 110, 50, "Compare routine")
  ComboBoxGadget(#Event_CompareRoutine, 20, 170, 90, 22)
    AddGadgetItem(#Event_CompareRoutine, #PURECOPY_COMPARE_NONE, "None")
    AddGadgetItem(#Event_CompareRoutine, #PURECOPY_COMPARE_DATE, "Date")
    AddGadgetItem(#Event_CompareRoutine, #PURECOPY_COMPARE_CRC, "CRC checksum")
    AddGadgetItem(#Event_CompareRoutine, #PURECOPY_COMPARE_SIZE, "Size")
    AddGadgetItem(#Event_CompareRoutine, #PURECOPY_COMPARE_EXISTS, "Exists")
    AddGadgetItem(#Event_CompareRoutine, #PURECOPY_COMPARE_ASKCALLBACK, "Ask")
    SetGadgetState(#Event_CompareRoutine, #PURECOPY_COMPARE_DATE)
   
Frame3DGadget(#PB_Any, 130, 50, 110, 105, "Set file properties")
  CheckBoxGadget(#Event_SetFilePropertiesCreated, 140, 70, 90, 20, "Created")
    SetGadgetState(#Event_SetFilePropertiesCreated, 1)
  CheckBoxGadget(#Event_SetFilePropertiesAccessed, 140, 90, 90, 20, "Accessed")
    SetGadgetState(#Event_SetFilePropertiesAccessed, 1)
  CheckBoxGadget(#Event_SetFilePropertiesModified, 140, 110, 90, 20, "Modified")
    SetGadgetState(#Event_SetFilePropertiesModified, 1)
  CheckBoxGadget(#Event_SetFilePropertiesAttributes, 140, 130, 90, 20, "File attributes")
    SetGadgetState(#Event_SetFilePropertiesAttributes, 1)



TextGadget(#PB_Any, 130, 165, 110, 18, "Copyright:", #PB_Text_Center)
HyperLinkGadget(#Event_Website, 143, 183, 82, 20, "Daniel Obermeier", $FF0000)




Repeat
  Define EventID = WaitWindowEvent()
 
  Select EventID
  Case #PB_Event_CloseWindow
    End
   
   
  Case #PB_Event_GadgetDrop
    Select EventGadget()
    Case #Event_ImageInput
      InputFilepath = EventDropFiles()
      FilesCount = CountString(InputFilepath, #LF$) + 1
     
      InputFiles = ""
      For FileIndex = 1 To FilesCount
        InputFiles + _ShortcutTarget(StringField(InputFilepath, FileIndex, #LF$)) + #LF$
      Next
      InputFiles = Left(InputFiles, Len(InputFiles) - 1)
     
      If FilesCount = 1
        DrawFilepathIcon(#I_Input, InputFiles, #Param_Default)
        SetGadgetState(#Event_ImageInput, ImageID(#I_Input))
      Else
        DrawFilepathIcon(#I_Input, "", #Param_Directory)
        SetGadgetState(#Event_ImageInput, ImageID(#I_Input))
      EndIf
     
      GadgetToolTip(#I_Input, InputFiles)
     
      If OutputFilepath
        DisableGadget(#Event_Start, 0)
      EndIf
     
     
    Case #Event_ImageOutput
      OutputFilepath = EventDropFiles()
      FilesCount = CountString(OutputFilepath, Chr(10)) + 1
     
      GadgetToolTip(#I_Output, OutputFilepath)
     
      If FilesCount = 1
        OutputFilepath = _ShortcutTarget(OutputFilepath)
       
        If FileSize(OutputFilepath) <> -2
          OutputFilepath = GetPathPart(OutputFilepath)
        EndIf
       
        DrawFilepathIcon(#I_Output, OutputFilepath, #Param_Default)
        SetGadgetState(#Event_ImageOutput, ImageID(#I_Output))
       
        If InputFiles
          DisableGadget(#Event_Start, 0)
        EndIf
      Else
        DrawFilepathIcon(#I_Output, OutputFilepath, #Param_Unknown)
        SetGadgetState(#Event_ImageOutput, ImageID(#I_Output))
       
        DisableGadget(#Event_Start, 1)
        OutputFilepath = ""
      EndIf
     
      GadgetToolTip(#I_Output, OutputFilepath)
    EndSelect
   
   
  Case #PB_Event_Gadget
    Select EventGadget()
    Case #Event_ImageOutput
      If EventType() = #PB_EventType_LeftClick
        OutputFilepathTemp.s = PathRequester("Choose output directory", OutputFilepath)
        If OutputFilepathTemp
          OutputFilepath = OutputFilepathTemp
         
          DrawFilepathIcon(#I_Output, OutputFilepath, #Param_Default)
          SetGadgetState(#Event_ImageOutput, ImageID(#I_Output))
         
          DisableGadget(#Event_Start, 0)
        EndIf
      EndIf
     
    Case #Event_Website
      RunProgram("http://www.jilocasin.de")
     
    Case #Event_Start
      StartPureCopy()
     
    EndSelect
  EndSelect
 
 
ForEver



DataSection
  PURECOPY_INCLUDEEXECUTABLE1:
    IncludeBinary "PureCopy_IncludeExecutable.exe"
  PURECOPY_INCLUDEEXECUTABLE2:
EndDataSection
Gruß,
Falko
Bild
Win11 Pro 64-Bit, PB_6.11b1
_v4
Beiträge: 26
Registriert: 16.11.2012 13:36

Re: Code funktioniert leider so nicht

Beitrag von _v4 »

Danke. Code scheint zu funktionieren. In dieser Data-Section siehts so aus als würde das Programm selbst geladen werden.
Benutzeravatar
Falko
Admin
Beiträge: 3535
Registriert: 29.08.2004 11:27
Computerausstattung: PC: MSI-Z590-GC; 32GB-DDR4, ICore9; 2TB M2 + 2x3TB-SATA2 HDD; Intel ICore9 @ 3600MHZ (Win11 Pro. 64-Bit),
Acer Aspire E15 (Win11 Home X64). Purebasic LTS 6.11b1
HP255G8 Notebook @AMD Ryzen 5 5500U with Radeon Graphics 2.10 GHz 3.4GHz, 32GB_RAM, 3TB_SSD (Win11 Pro 64-Bit)
Kontaktdaten:

Re: Gelöst - WebDAV Code PB 5.00 Korrektur

Beitrag von Falko »

Das freut mich, wenn es soweit bei dir funktioniert.
Wenn du dieses Programm als PureCopy_IncludeExecutable.exe compilierst,
denke ich auch, das es so geladen wird. Hab's aber noch nicht ausprobiert und
weiß jetzt nicht was da passiert.

Gruß,
Falko
Bild
Win11 Pro 64-Bit, PB_6.11b1
Antworten