I am trying to set up a small intranet and was wondering if there is a way to determine the client’s workstation name (for example, Computer Name in Control Panel/Identification). I can then interrogate a database and generate a form to indicate what applications this workstation is licensed for.
HTML isn’t sophisticated enough to determine that information and scripting languages have that kind of check turned off. However, the Windows API can be very useful in providing this kind of information, but to access it through a Web application, the code would have to run within a compiled component, such as an ActiveX control or ActiveX document. The Windows API named GetComputerNameA can do this task nicely. You can either call GetComputerNameA directly or create a wrapper function around it, then call your wrapper function.
For example, if you insert the following code into your custom ActiveX control, you can get the client computer’s name to appear in a Message Box. By the way, this code will work in other types of VB projects, as well.
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As LongPublic Function GetComputer() As String Dim lpBuffer As String * 255 Dim Length As Long Length = GetComputerName(lpBuffer, Len(lpBuffer)) If Length > 0 Then GetComputer = lpBuffer Else GetComputer = "
" End If End Function' Insert this in an event procedure, such as ' Command1_Click()' ...of course, this assumes that you actually ' have a command button on a form named Command1.Private Sub Command1_Click()MsgBox GetComputerEnd Sub