Why doesn't that code work?? Please try it and see what it gives you!Code:FileCopy App.Path + "\LSS.exe", GetWinDir(144) + "\"
Printable View
Why doesn't that code work?? Please try it and see what it gives you!Code:FileCopy App.Path + "\LSS.exe", GetWinDir(144) + "\"
GetWinDir() is not a VB function.
this is what I have in a module!
and then I want to copy the current file that is running to the windows directory using this codeCode: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 it gives me a Path/File Access Error!Code:FileCopy App.Path + "\LSS.exe", GetWinDir(144) + "\"
Why Are you passing a variable to your getwindir finction? It's not being used.
But anyway use the & not +
Try this:Code:FileCopy App.Path + "\LSS.exe", GetWinDir(144) & "\"
Hope this helps!Code:Dim FindWinDir as string, WinDir as string
WinDir = Space(144)
FindWinDir = GetWindowsDirectory(WinDir, 144)
WinDir = Trim(WinDir)
FileCopy App.Path + "\LSS.exe", WinDir & "\"
:P