Sooner Posted June 27, 2005 Posted June 27, 2005 I have a text file that resembles hundreds of lines of the following:PE2421D1="33421"PE2422D1="33422"PE2423D1="33423"PE2424D1="33424"PE2425D1="33425"PE2426D1="33426"PE2427D1="33427"PE2428D1="33428"The first is the name of a machine and the second item is what I need to get into some sort of useable format. Sometimes the names and values make logical sense and other times they don't have any correlation at all.My delima is with trying to read through this file, and match the name of the machine in the file with the name of the machine on which the program is being executed, then write the "string" to someplace on that machine, generally the registry or ini files for most of our work. I have dabbled in VB for a little bit but haven't touched it since .NET was released, so I am very rusty. I am looking for the simplest way possible of completing the process on each machine, and the software will be ran on each individual machine so connecting remotely is not an issue here.Any help would be greatly appreciated.
saprouzy Posted July 4, 2005 Posted July 4, 2005 Declare Function GetComputerNameA Lib "kernel32" (ByVal lpBuffer As String, nSize As Long) As LongPublic Function GetComputerName() As StringDim sResult As String * 255 GetComputerNameA sResult, 255 GetComputerName = Left$(sResult, InStr(sResult, Chr$(0)) - 1)End Functionthis code will give u the computer name try reading the file into some buffer or something and search for the machine name in it, and then get the string that follows
jdoe Posted July 4, 2005 Posted July 4, 2005 Declare Function GetComputerNameA Lib "kernel32" (ByVal lpBuffer As String, nSize As Long) As LongPublic Function GetComputerName() As StringDim sResult As String * 255 GetComputerNameA sResult, 255 GetComputerName = Left$(sResult, InStr(sResult, Chr$(0)) - 1)End Functionthis code will give u the computer nameYour GetComputerName function is not really a good use of this API but anyway, using this single code line below to get computer name, runs 3 times faster than the API.Dim sComputerName as StringsComputerName = Environ$("COMPUTERNAME")
saprouzy Posted July 4, 2005 Posted July 4, 2005 (edited) cool... but as i read about it, it seems it doesn't work with Windows 98 Edited July 5, 2005 by saprouzy
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now