Results 1 to 4 of 4

Thread: Why does this work! (File Copy Method)

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    879

    Why Doesn't This Work

    Code:
    FileCopy App.Path + "\LSS.exe", GetWinDir(144) + "\"
    Why doesn't that code work?? Please try it and see what it gives you!
    Visual Basic 6.0
    Visual C++ 5
    Delphi 5


  2. #2
    Hyperactive Member
    Join Date
    Oct 2000
    Posts
    400
    GetWinDir() is not a VB function.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    879
    this is what I have in a module!

    Code:
    Public Declare Function GetWindowsDirectory _
    Lib "kernel32" Alias "GetWindowsDirectoryA" _
    
    Public Function GetWinDir(dir As Integer) As String
        Dim WinDir As String * 255
        Dim StrLn As Long
        WinDir = Space(255)
        StrLn = 254
        Call GetWindowsDirectory(WinDir, StrLn)
        Trim$ (WinDir)
        GetWinDir = WinDir
    End Function
    and then I want to copy the current file that is running to the windows directory using this code
    Code:
    FileCopy App.Path + "\LSS.exe", GetWinDir(144) + "\"
    And it gives me a Path/File Access Error!
    Visual Basic 6.0
    Visual C++ 5
    Delphi 5


  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Question Question...

    Why Are you passing a variable to your getwindir finction? It's not being used.

    But anyway use the & not +
    Code:
    FileCopy App.Path + "\LSS.exe", GetWinDir(144) & "\"
    Try this:

    Code:
    Dim FindWinDir as string, WinDir as string
    
    WinDir = Space(144)
    FindWinDir = GetWindowsDirectory(WinDir, 144)
    WinDir = Trim(WinDir)
    
    FileCopy App.Path + "\LSS.exe", WinDir & "\"
    Hope this helps!
    :P
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width