저는 (다시) DLL을 작성하는 것이 가장 쉬운 방법이라고 생각하지 않습니다. information (printers in this case)을 검색하려면 WMI을 사용하지 않으시겠습니까? (here에서 차용 코드 샘플)
ManagementScope objScope = new ManagementScope(ManagementPath.DefaultPath); //For the local Access
objScope.Connect();
SelectQuery selectQuery = new SelectQuery();
selectQuery.QueryString = "Select * from win32_Printer";
ManagementObjectSearcher MOS = new ManagementObjectSearcher(objScope, selectQuery);
ManagementObjectCollection MOC = MOS.Get();
foreach (ManagementObject mo in MOC) {
listBox1.Items.Add(mo["Name"].ToString().ToUpper());
}
얻을 도메인 건너 알려진 프린터이 사용하려면 :
ConnectionOptions objConnection = new ConnectionOptions();
objConnection.Username = "USERNAME";
objConnection.Password = "PASSWORD";
objConnection.Authority = "ntlmdomain:DDI"; //Where DDI is the name of my domain
// Make sure the user you specified have enough permission to access the resource.
ManagementScope objScope = new ManagementScope(@"\\10.0.0.4\root\cimv2",objConnection); //For the local Access
objScope.Connect();
SelectQuery selectQuery = new SelectQuery();
selectQuery.QueryString = "Select * from win32_Printer";
ManagementObjectSearcher MOS = new ManagementObjectSearcher(objScope, selectQuery);
ManagementObjectCollection MOC = MOS.Get();
foreach (ManagementObject mo in MOC) {
listBox1.Items.Add(mo["Name"].ToString().ToUpper());
}
을
다음 코드는 모든 로컬에 설치된 프린터를 검색하는 것입니다 물론, 어떤 기준도 지정하지 않았 으면 원하는대로 목록이 "필터링"되지 않습니다. 하지만 여기서부터 스스로 관리 할 수 있다고 확신합니다.