|
will thanks to all
ok first iam using win xp
iam going to use this program for my own
the reason iam making this program to make it easy to setup and install all needed .exe and dll. to play with joystick
this is the program
http://img835.imageshack.us/img835/3469/iplayp.jpg[^]
it has 4 button
install: install libusb-win32-filter-bin-0.1.10.1.exe to make the ps3 sixaxies work with windows xp
copy : to copy 2 files libusb0.dll and ps3sixaxis_en to C:\WINDOWS\system32 (to run ps3sixaxis_en when need to play with joystick)
Xpadder : is program to configure the needed button in the joystick (not mine)
exit : simple exit the program
the code i made is
_______________________________
Public Class Form1
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Dir("C:\WINDOWS\system32\ps3sixaxis_en.exe") <> "" Then
MsgBox("installed successfully")
Else
MsgBox("File was not copied")
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
System.Diagnostics.Process.Start("C:\Program Files\Iplay\xpadder.exe")
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
End
End Sub
Private Sub Process1_Exited(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Label1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
System.Diagnostics.Process.Start("C:\Program Files\Iplay\libusb-Win32 Setup.exe")
End Sub
End Class
_________________________________________ _______________________________________________________________________
and the i used path
System.Diagnostics.Process.Start("C:\Program Files\Iplay\libusb-Win32 Setup.exe")
because i made setup installer to install (Xpadder and ps3sixaxis_en.exe and libusb0.dll & libusb-win32-filter-bin-0.1.10.1.exe ) to C:\Program Files\Iplay
when i said button that copy 2 file
(i meant the code it self) if there anyway that copy 2 files to C:\WINDOWS\system32
how you want me to wright a code while i dont know anything about the copy thing
(i started learning vb2010 2 day's ago)
thanks for the help
|
|
|
|
|
First, always try Google: http://www.google.com/search?q=copy+files+in+vb&hl=en
The first result of that search being: http://www.control.com/thread/1026222696
In which someone says "See the FileCopy method in VB.
The syntax is:
FileCopy SourceFile, DestinationFile".
Then, if that's not enough for you, back to Google:
http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=vb+FileCopy
which brings us to: http://msdn.microsoft.com/en-us/library/36xbexyf(v=VS.90).aspx
and if that's not enough for you then you probably shouldn't be using the internet.
Remember, always try Google.
|
|
|
|
|
Ok: First use the "code block"-tag in your messages on codeproject - this will format your code in a readable way.
@Copy: You didn't get my hint about File.Copy? Open VisualStudio-Help type File.Copy into the index-search field.
You will find examples for every .NET language...
I did it for you, and here is the example from VS-Help:
Imports System
Imports System.IO
Public Class Test
Public Shared Sub Main()
' Specify the directories you want to manipulate.
Dim path As String = "c:\temp\MyTest.txt"
Dim path2 As String = path + "temp"
Try
Dim fs As FileStream = File.Create(path)
fs.Close()
' Ensure that the target does not exist.
File.Delete(path2)
' Copy the file.
File.Copy(path, path2)
Console.WriteLine("{0} copied to {1}", path, path2)
' Try to copy the same file again, which should fail.
File.Copy(path, path2)
Console.WriteLine("The second Copy operation succeeded, which was not expected.")
Catch e As Exception
Console.WriteLine("The second Copy operation failed, as expected.")
End Try
End Sub
End Class
So If you don't know how to use the framework and language - first figure out where to find documentation or help (day 1). Try to experiment with your code, and you will learn a lot by "doing". Here on codeproject you can find "real experts", they will help you if you have a real problem (even if it is a "beginner-problem"), but not doing your "homework" will not help you to get good answeres here. The question-style: "I want you to solve my problem" doesn't work here!
Edit: Correction: Ok sometimes it works - Tom Foswick had compassion with you - and gave you a perfect answer while I wrote this.
|
|
|
|
|
Hi,
I won't tell you that you shouldn't do this or that your question is all wrong. I'll just try to give you an answer you can use.
There are a few nice built-in .NET methods for copying a file. Here are two:
IO.File.Copy(sourceFileName,destFileName)
My.Computer.FileSystem.CopyFile(sourceFileName,destinationFileName)
They both do the same thing, though I prefer the first example. The second example is not available if you are programming in C#, so it helps with portability not to use it.
Others have already warned you about the problems with hard-coding these paths and with possible/probable security problems in copying to your system directory
Now, with regards to your second question (running 392.exe) without knowing the path, the short answer is, "No", it is not possible.
The long answer is, "Yes", it is possible, but it is clunky. There are two strategies that I can think of. The first strategy involves environment variables, and someone else already talked about that. I wouldn't recommend that approach for a bunch of reasons.
The second approach involves searching for the file, then running it. The problems with this are:
- It is potentially quite slow. It could take a long time to find the file.
- It is potentially dangerous. If there was another file named "392.exe" that you didn't want to run, the code might find it and run it anyway.
However, the code for finding the file and running it would look something like this:
Private Function FindFile(ByVal fileName As String, ByVal searchDirectory As String) As String
Dim fullPath As String = ""
If Not IO.Directory.Exists(searchDirectory) Then Throw New IO.DirectoryNotFoundException
fullPath = IO.Path.Combine(searchDirectory, fileName)
If Not IO.File.Exists(fullPath) Then
fullPath = ""
Try
For Each subDirectory As String In IO.Directory.GetDirectories(searchDirectory)
fullPath = FindFile(fileName, subDirectory)
If fullPath <> "" Then Exit For
Next
Catch uaException As UnauthorizedAccessException
fullPath = ""
End Try
End If
Return fullPath
End Function
This function will search all subdirectories to which your app has access for the file in question. You would use it like this:
myFile = FindFile("392.exe", "C:\")
If IO.File.Exists(myFile) Then Process.Start(myFile)
This would search all directories and subdirectories of C:\ for a file called "392.exe". If it finds it, it will return the full path to that file and set myFile to that path. Otherwise, it will return "", and myFile will be "". We check to see if myFile exists, and if so, we run it.
Now, as you can imagine, this could take a while. So, it is best not to unleash FindFile() on your C:\ root directory. Better to narrow it down a bit. .NET provides some really nice built-in functions for doing this. For example, if you just want to search all through the Program Files directory (and subdirectories), try:
myFile = FindFile("392.exe", Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles))
The function Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) will return the full path to the computer's Program Files directory, regardless of where that happens to be. You can reference other special folders in that same way. That is just one example.
Best of luck.
|
|
|
|
|
Thank you all
that helped me a lot
|
|
|
|
|
learn how to use google before posting questions. Because most of the time anything a beginner needs is available on google, you just have to search it right.
|
|
|
|
|
How can we get the Idleness time of a User on machine in VB.net
Used getlastinputinfo
SOFTDEV
Luck in life always exists in the form of an abstract class that cannot be instantiated directly and needs to be inherited by hard work and dedication.
modified on Tuesday, August 24, 2010 5:22 AM
|
|
|
|
|
You can use GetLastInputInfo[^] API.
This[^] CodeProject article contains a C# implementation.
Converting to VB.NET should not be a problem, especially with the help of this[^] page.
|
|
|
|
|
Thanks a lot , its been solved
SOFTDEV
Luck in life always exists in the form of an abstract class that cannot be instantiated directly and needs to be inherited by hard work and dedication.
|
|
|
|
|
Ah yes!
Probably you've edited your question when I was writing my answer.
I saw your edit after my post. Its very good that you solved your problem quickly.
Best Regards,
Nuri
|
|
|
|
|
I have just completed a particular project using VB6 and MS-ACCESS 6.0 and using the package and deployment wizard.I am able to run on standalone pcs(on one computer).Here both the .exe and MS-Access database file both are residing in the same computer.Now there is a need to make this project centralised on LAN.
So I have to make the MS-Access reside on one PC(Server) and exe on many pcs..so that the client from client pcs must be able to access the database placed in the Server(or that particular Pc).How can it be done on a simple Network(LAN)?What is the step by step procedure to obtain the solution.
I am using the following code in the connection string in VB:
con.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & (App.Path & "\abc.mdb") & ";Jet OLEDB:Database Password=efg;"
Anything to be changed here?Can anyone please give me a solution?Its very urgent...
|
|
|
|
|
The first thing is that app.path will parse to your local exe installation, whereas it will need to be \\servername\sharename
Other than that, assuming all your users have permissions to read and write the directory where your database is located, it should all be fine.
|
|
|
|
|
Where exactly I should give Servername\\sharename and how..Can you please explain in detail?
|
|
|
|
|
kokilag wrote: Where exactly I should give Servername\\sharename and how
con.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & (App.Path & "\abc.mdb") & ";Jet OLEDB:Database Password=efg;"
con.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ("\\servername\sharename\abc.mdb") & ";Jet OLEDB:Database Password=efg;"
Where servername is the name of the server that everyone is using on the LAN, and sharename is the name of the share on the server... eg: your server might be called dogbone with a share called dbfiles, so you would use \\dogbone\dbfiles\abc.mdb
|
|
|
|
|
Ok..thanks a lot.. I replaced the code with above statement and the project is working fine..I have also shared the folder which contains the database in the network.I have assumed my pc as the server.Now the project runs fine in my pc with the new path.Till now I was giving the app.path and was making the package using package and deployment wizard and running the project in individual pcs.Now can you please tell me how to proceed and how to make only exe run in another pcs and to make them access the database residing in the share folder in the network..(Pls note the folder is shared from my pc assuming my pc as the server?
|
|
|
|
|
suppose I want to make a work station pc which is not a server type as a server to store the database,then what will be the code to access the database residing on a network pc which is not a server type?
|
|
|
|
|
|
kereljansen wrote: The problem is the comma in the " 's Heerenberg"
That character is an apostrophe not a comma. See here[^] and see if that helps.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
your code has two problems:
1.
when tblocation.Text contains either nothing or some special characters (including single quote, double quote, parenthesis, ...) then your VB statement will happily concatenate everything, however it will not result in a valid SQL statement.
2.
when a malicious user enters some special stuff through tblocation.Text, the net result may be a valid SQL statement with side effects you don't want; by providing some text, a quote, a closing parenthesis, a semi-colon, then whatever follows would be executed as a second SQL statement, and could e.g. delete an entire table. This problem is known as "SQL injection attacks".
There are basically two solutions:
1.
the best one is using SqlParameter, which means no string concatenation is used holding user input; all user input is handled separately, see SqlCommand.AddParameter().
This approach solves both problems.
2.
check and filter the textbox input; make sure there is nothing you don't want. If you want to allow quotes (as required in your example), then you may have to resort to special encoding, e.g. you could double the character on insertion, telling the database engine a single quote is required in the data.
|
|
|
|
|
The dirty fix is to replace ' with '' in your string.
That'll work but it's not a good idea for the reasons described by Luc.
Use parameters when inserting values into SQL like this.
|
|
|
|
|
thanks.
I think you clicked the wrong reply widget though.
|
|
|
|
|
sample (i have text like this):
username:marin;password:12345;lastlogin:12.12.2012;
i encrypt it with password(1111) using (http://www.di-mgt.com.au/properpassword.html[^]) and then i have something like:
FS238sdshdio92upishSDSDJfssf87s9dSFSSJDJ bla bla bla
and i save that "bla bla" into a file somewhere in application directory and when i start application again i decrypt and get info from file.
thats safe encryption but what for if annyone can see my application executable code and see with what password i encrypted it! or i am wrong?
thanks!
|
|
|
|
|
Nope, you're not wrong! A .NET assembly can be reversed with .NET Reflector and can figure out what you did to encrypt it. Tha's what obfuscators are for.
And if it was THAT critical, you should probably write the crypt/decrypt code in C++, not managed code.
|
|
|
|
|
Don't put the password in the executable; basic security!
It's time for a new signature.
|
|
|
|
|
How you encrypt this depends on who you are protecting it from and how important it is.
If this is a client-server application, a better option would be storing the encryption key on the server, and randomly generating it the first time the server runs. The client never sees the decrypted information, you just use a different "LoginFromEncryptedCredentials" method that passes the raw encrypted data, which the server decrypts and tries to process. When you want to store credentials, you call "GetEncryptedCredentialsFromServer" and pass it the information you want to encrypt. The key here is that the client machine NEVER sees the encryption key. If the client machine EVER has it in memory, then it can be retrieved.
If this is just a client application with no server, and you are saving the current user's credentials, you would be much better served encrypting the file with built-in windows file system encryption. This would hide it from everyone except the current user in a secure fashion.
|
|
|
|
|