Obtaining Client-Specific Information with a Web Application, Page 2
Creating an ActiveX Object
ActiveX objects for ascertaining client information include WScript.Network and WScript.Shell. WScript.Network can be used to determine the active user, for example, and WScript.Shell can be used to query information like the path to the MyDocuments folder. For a complete reference for these ActiveX libraries refer to the MSDN help documentation.
To create an instance of the desired ActiveXObject you can invoke new ActiveXObject passing in the name of the library as a string that you want to create. The following code demonstrates how to use the debugger; statement to break into the code and create an instance of WScript.Network and WScript.Shell. With these two objects the UserName and the path to the special folder MyDocuments is obtained (refer to Listing 1).
The end of the listing contains a statement that starts
with var jsonObject. Programmers used to create objects by
Object() and referring to the
desired properties. The revised syntax above is part of JSON
lightweight data-interchange format that is a subset of
readable form, and the technology plays in the same space as
XML. The statement above creates an object with two
properties: UserName and MyDocuments.
Paul Kimmel is the VB Today columnist for www.codeguru.com and has written several books on object- oriented programming and .NET. Check out his upcoming book Professional DevExpress ASP.NET Controls (from Wiley) now available on Amazon.com and fine bookstores everywhere. Look for his upcoming book Teach Yourself the ADO.NET Entity Framework in 24 Hours (from Sams). You may contact him for technology questions at pkimmel@softconcepts .com. Paul Kimmel is a Technical Evangelist for Developer Express, Inc, and you can ask him about Developer Express at firstname.lastname@example.org and read his DX blog at http:// community.devexpress.com/blogs/paulk.