Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to retrieve PC name 2

Status
Not open for further replies.

Avacha

Technical User
Apr 1, 2002
69
US
Please Help!
How to get PC name using vb 6 on XP and Widows 2000
operation systems.Does same one knows API or vb function.
Thanks.

 
I think that thread222-604971 was the last time we answered this one
 
There is a way of doing this, first download the DNS OCX component from ww.dart.com,install it. Next open a new project add the DNS component, there is example code on the site on how to use it. Hope this helps.
 
jyoung - There is a much simpler way than that. Check out the GetComputerName API (as strongm is pointing to).

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
oh, oh, the dreaded (at least by me) Environ solution rears its head again...
 
A quick keyword search in this forum would find most of the drawbacks, but here's a summary: the environment variables, which are what are returned by Environ, can be easily modified by the user and/or other applications. They are therefore not guaranteed to contain correct information.
 
VBProgrammer666

Have a look at thread222-542981 for a discussion on Environ

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Strongm - don't want to get into a pissing contest with you,but....I think your blanket dismissal of Environ is a bit of an overkill. I believe Environ has its uses.

I work as a developer on production support of a large scale, thin-client intranet based app used by thousands of employees on a daily basis. We use Environ in selected circumstances with no problem. If an end user did change some of their environment settings then they risk losing access to the app. They would learn pretty quickly after a call to the help desk not to do that again.

A lot of people read and trust your statements (including me!), so I would be more hesitant before issuing a pronouncement like that without at least mentioning a reason.

Thanks.
 
Perhaps it is just a personal foible, but given two function calls that supposedly return the same result, one of which I know is not guaranteed to give 100% reliable results, and another that is...well, I prefer the reliable one and would always recommend it over the unreliable one.
 
if you are using backend as sqlserver
"use master
select @@servername
will give you your computername
 
> They would learn pretty quickly after a call to the help desk not to do that again

Bearing in mind it may have nothing to do with the user. The setting may have been modified by an external application. I think I would tend to go for a more reliable solution as well.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top