DOCUMENT:Q192300 30-SEP-1999 [foxpro] TITLE :HOWTO: Use ADSI for Printer Information and Control PRODUCT :Microsoft FoxPro PROD/VER:WINDOWS:6.0; winnt:2.5 OPER/SYS: KEYWORDS:kbADSI kbCOMt kbvfp600 kbDSupport ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, version 6.0 - Microsoft Active Directory Service Interfaces, version 2.5 ------------------------------------------------------------------------------- SUMMARY ======= The Active Directory Service Interfaces (ADSI) can be used to obtain network printer information and to control printers from within Visual FoxPro. This article describes how to accomplish this. MORE INFORMATION ================ NOTE: To use the following example, the Active Directory Service Interfaces must be installed. It is on the Microsoft Developer Network CD or you can download it from the following URL: http://www.microsoft.com/windows/server/Technical/directory/ ADSI is a Component Object Model (COM) based interface for accessing directory services. Each element of the network, such as users, printers and computers, can be treated as an object. Accessing the user object's properties allows the developer to get information about the printer and to control print functions. The following code demonstrates how to accomplish this. Save the following code to a program file and run the program: Sample Code ----------- *-- Code begins here. PUBLIC oadsiprint oadsiprint=NEWOBJECT("adsiprint") oadsiprint.SHOW RETURN DEFINE CLASS adsiprint AS FORM HEIGHT = 345 WIDTH = 457 DOCREATE = .T. AUTOCENTER = .T. CAPTION = "ADSI Printer Control Sample" NAME = "ADSIPrint" ADD OBJECT text1 AS TEXTBOX WITH ; VALUE = "WinNT://MyServer", ; HEIGHT = 23, ; LEFT = 24, ; TOP = 299, ; WIDTH = 238, ; NAME = "Text1" ADD OBJECT label1 AS LABEL WITH ; CAPTION = "ADS Path to Printer Server:", ; HEIGHT = 25, ; LEFT = 24, ; TOP = 274, ; WIDTH = 202, ; NAME = "Label1" ADD OBJECT cmdfind AS COMMANDBUTTON WITH ; TOP = 285, ; LEFT = 283, ; HEIGHT = 37, ; WIDTH = 97, ; CAPTION = "\