'To get the default printer name

To get the default printer name .

This code is what I am using, In order to get this

<script language="javascript" type="text/javascript">


    function getDefaultPrinterName() {
        var oShell = new ActiveXObject("WScript.Shell");
        sRegVal = 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Device';
    
        var sName = oShell.RegRead(sRegVal)
        if (sName == '') {
            alert('Please, Check the Default Printer');
        }
       
        return sName;
    }
    </script>

I would like to know whether this value will be same across all the windows release ?

'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Device';

Is there any better way to get the default printer name using ActiveX and JavaScript ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source