In my application I am using j-interop to check Win32_PrintJob class.
I am executing a query like the following one to check if there is any print job on a given printer queue:
SELECT * FROM Win32_PrintJob WHERE DriverName=\"MyPrinter\"
Here is the line to execute the query:
String sQuery = "SELECT * FROM Win32_PrintJob WHERE DriverName=\"MyPrinter\"";
IJIDispatch wbemServices_dispatch =
(IJIDispatch)JIObjectFactory.narrowObject(results[0].getObjectAsComObject());
results = wbemServices_dispatch.callMethodA("ExecQuery", new Object[] {
new JIString(sQuery), JIVariant.OPTIONAL_PARAM(),
});
Hello
In my application I am using j-interop to check Win32_PrintJob class.
I am executing a query like the following one to check if there is any print job on a given printer queue:
SELECT * FROM Win32_PrintJob WHERE DriverName=\"MyPrinter\"
Here is the line to execute the query:
String sQuery = "SELECT * FROM Win32_PrintJob WHERE DriverName=\"MyPrinter\"";
IJIDispatch wbemServices_dispatch =
(IJIDispatch)JIObjectFactory.narrowObject(results[0].getObjectAsComObject());
results = wbemServices_dispatch.callMethodA("ExecQuery", new Object[] {
new JIString(sQuery), JIVariant.OPTIONAL_PARAM(),
});
And the lines to get the result:
IJIDispatch wbemObjectSet_dispatch =
(IJIDispatch)JIObjectFactory.narrowObject(results[0].getObjectAsComObject());
JIVariant variant = wbemObjectSet_dispatch.get("_NewEnum");
IJIComObject object2 = variant.getObjectAsComObject();
IJIEnumVariant enumVARIANT = (IJIEnumVariant)JIObjectFactory.narrowObject(object2.queryInterface("00020404-0000-0000-C000-000000000046"));
JIVariant Count = wbemObjectSet_dispatch.get("Count");
count = Count.getObjectAsInt();
In my environment I can use 2 printers:
- a local one
- a network printer (which I dont have rights to change properties)
=> When I execute the code using my local printer, everything works fine.
=> When I execute the code using the network printer, an exception occurs on the following line:
JIVariant Count = wbemObjectSet_dispatch.get("Count");
I made a debug and the wbemObjectSet_dispatch dont have the Count key on the HashMap.
Why, the code is not working for the network printer? why for that printer the "Count" key is not on the HashMap?
Thanks
Regards