[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

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.
0
MatthiasK
Asked:
MatthiasK
  • 7
  • 6
  • 3
  • +2
1 Solution
 
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 new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 7
  • 6
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now