Can I / how can I detect whether a particular printer has been installed? I know the exact name of the printer.
Any help would be greatly appreciated - thanks.
Professional Software Development Tools
Can I / how can I detect whether a particular printer has been installed? I know the exact name of the printer.
Any help would be greatly appreciated - thanks.
I don't know if it will work on non-NT system but I think that you can try this:
result = Registry.GetKeyNames(HKEY_LOCAL_MACHINE, "\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers");
result = Dialog.Message("Notice", result[1], MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
It will enumerate all printers on your computer (my example only show the first)
Eliminator
Good one Eliminator.
We do not have a direct action to do this. I'll bet that there is a key somewhere on non NT machines in the registry.
Adam.
Thanks for your help.
In XP and 2000, the registry location is different:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\Current Version\Devices
We decided to instead go with a script that uses the Windows FileOpen function. See http://msdn2.microsoft.com/en-us/library/ms536027.aspx
Sorry, I didn't check on other but you can use a System.GetOSName and for each os use a different key.
Sorry for my mistake![]()
Eliminator
How would I handle the error if no printer is installed?
Getting quite frustrated, can I even suppress the error?
Any help please... All i need to do is detect whether or not a printer is installed, but I get "a nil value" if no printer is found.
FOR NT
FOR NON NTCode:result = Registry.GetKeyNames(HKEY_LOCAL_MACHINE, "\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers"); if result == "" then ~SETUP YOUR ACTION FOR NO PRINTER HERE else ~SETUP YOUR ACTION FOR YES PRINTER HERE end
Code:result = Registry.GetKeyNames(HKEY_CURRENT_USER "\Software\Microsoft\Windows NT\Current Version\Devices\\Printers"); if result == "" then ~SETUP YOUR ACTION FOR NO PRINTER HERE else ~SETUP YOUR ACTION FOR YES PRINTER HERE end
or something similar