Resolve ComputerNames in VB

How can I resolve my Computername in VB4 ?
The answer what I got from vbwayne is for for the current login
name not the Cname.
MatthiasKAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

adityauCommented:
Use GetComputerName API
0
korkyCommented:
Here is some code you can use:

Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Const MAX_COMPUTERNAME_LENGTH = 15
Function GetComputerNameAPI() As String
    Dim Buffer As String * MAX_COMPUTERNAME_LENGTH
    GetComputerName Buffer, MAX_COMPUTERNAME_LENGTH
    GetComputerNameAPI = Trim(Buffer)
End Function

Private Sub Command1_Click()
    MsgBox GetComputerNameAPI()
End Sub

/Hope it helps
/Korky le petit mongole
0
MatthiasKAuthor Commented:
Hi korky,
thanks, this is general working but for some reasons only on NT plattforms, not WIN95 ?!
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

vindevogelCommented:
In VB6, thus I think in VB4 too, you can use the Winsock control to get the local host name.

If that's sufficient, here's how to do it :

Create a form, add the Winsock control to your toolbox, drag one onto your form and add this code to the click event of a commandbutton :

Private Sub Command1_Click()
    MsgBox Winsock1.LocalHostName
End Sub

Maybe this gets around your Win95 problem.
0
MatthiasKAuthor Commented:
Thats cool and works, where can I found out more about winsock objects ??
0
korkyCommented:
MSDN!?
0
vindevogelCommented:
I think there's enough documentation on it in the Help or MSDN.

Basically, it's used for other things than this, but ... it's a feature you can use for some other stuff too.

Winsock is mostly used in Internet applications, maybe you can find books on that ("Developing Internet applications with VB")

Korky : thanks for answering on my comment ...
0
korkyCommented:
vindevogel: I'm kind of new around here, is there a difference?
0
vindevogelCommented:
Yes there is ...

You answered a question, thus locking it for other users.  Most posters and users don't really appreciate that, but well ... (Nobody else looks at it anymore because it's answered)


Your answer was right, but didn't help Matthias, because he had a problem with Win95.

I suggested something, that worked out fine for him.

You answered again, locking the question again.

Matthias can only accept your answer (since I can't answer).  He can therefore only award points to you, even if he wants to give them to me for solving his problem.  

When you "suggest" something, you post it as a comment.  When you're sure of your answer, you post it as an answer.
Moreover, the poster will generally ask to "answer" the question when he resolved his problem.  He can then choose between the people who gave him answers.

Not that I'm so keen on the points, but I like to get credit for what I post.  I take pride in my grades and points.  Just like I take pride in the software I write.  It's a business mentality, I guess.

Yves
0
korkyCommented:
sorry!
MatthiasK: can you please reject my answer
0
MatthiasKAuthor Commented:
I'm also new here, how can I pass this points to vindevogel ?
0
korkyCommented:
I think you must way until he gives you an other answer...
0
vindevogelCommented:
That's right

I must answer this question, and now you can accept it.

Accepting it automatically transfers the points to my expert account.

Thanks
Yves
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
korkyCommented:
Capitalistic, ain't it?
0
vindevogelCommented:
Hey, I live in Belgium ...  ;-)

Here, it's perfectly normal and accepted to be a bit capitalistic.

It's even perfectly normal to take bribes, some politicians seem to think.

0
korkyCommented:
Bon, ok!
Ciao ma poule!
0
ThaSmartUnoCommented:
you can click where it says accept as comment also MatthiasK ... should be right near any of the comments.  So just look for one of vindevogels comments ... and click it
0
vindevogelCommented:
ThaSmartUno: you're right ... I'm still stuck with the old interface of this site.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.