Jump to content

Recommended Posts

Posted

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.


Posted

Declare Function GetComputerNameA Lib "kernel32" (ByVal lpBuffer As String, nSize As Long) As Long

Public Function GetComputerName() As String
Dim sResult As String * 255
   GetComputerNameA sResult, 255
   GetComputerName = Left$(sResult, InStr(sResult, Chr$(0)) - 1)
End Function

this 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

Posted
Declare Function GetComputerNameA Lib "kernel32" (ByVal lpBuffer As String, nSize As Long) As Long

Public Function GetComputerName() As String
Dim sResult As String * 255
   GetComputerNameA sResult, 255
   GetComputerName = Left$(sResult, InStr(sResult, Chr$(0)) - 1)
End Function

this code will give u the computer name

Your 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 String

sComputerName = Environ$("COMPUTERNAME")

:)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...