+ Post New Thread
Results 1 to 9 of 9
Windows Thread, Disabling/re-enabling hardware graphics acceleration in Technical; I'm installing a new version of ProDesktop which tends to fall over on our kit if hardware graphics acceleration isn't ...
  1. #1

    Join Date
    Jan 2006
    Posts
    143
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Disabling/re-enabling hardware graphics acceleration

    I'm installing a new version of ProDesktop which tends to fall over on our kit if hardware graphics acceleration isn't disabled.

    Ideally I'd like to check hga when the program runs, and disable it if it's enabled. Given that this might affect other applications, I'd like to re-enable it at some point (logoff, shutdown etc).

    I've tried Googling, I've taken RegShots before and after, and I can't identify what changes I need to make in the background to make it 'just happen'.

    Can anyone help please?

    ETA - er, we're running Win2K Pro here

  2. #2

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,705
    Thank Post
    3,239
    Thanked 1,045 Times in 967 Posts
    Rep Power
    363

    Re: Disabling/re-enabling hardware graphics acceleration

    I asked how to do this on EE some time ago, here is the code I got to do it :

    Here you go, this function reads the current acceleration value from the registry and returns it. I wrote this code to be usable both in VB and VBScript, since I didn't have VB6 installed on the machine I wrote this on. To 'set' the Acceleration setting, just use a SetDWORDValue call instead of GetDWORDValue near the end of the function (or use DeleteValue if you want to set "full acceleration", since 0 is the default).

    '********************************

    Code:
    Const HKLM = &H80000002
    
    '
    ' GetAccelerationSetting
    '
    ' Reads current acceleration setting value from the registry.
    ' Returns 0-5 on success, or -1 if an error occurred reading
    ' the Device information.
    '
    
    Function GetAccelerationSetting()
      GetAccelerationSetting = -1
     
      Dim objReg, strDevice, intAccelValue, intErr
      Dim strKey, strValueName
      Dim objRegExp, colMatches, objMatch
     
      ' using WMI's StdRegProv to access the registry (making this code usable
      ' in both VB and VBS)
     
      On Error Resume Next
      Set objReg = GetObject("winmgmts:\\.\root\default:StdRegProv")
     
      If (Err.Number) Then Exit Function
     
      On Error Goto 0
     
      strKey = "HARDWARE\DEVICEMAP\VIDEO"
      strValueName = "\Device\Video0"
     
      intErr = objReg.GetStringValue(HKLM, strKey, strValueName, strDevice)
     
      If (intErr <> 0) Then Exit Function
     
      strKey = ""
     
      Set objRegExp = CreateObject("VBScript.RegExp")
      objRegExp.IgnoreCase = True
      objRegExp.Pattern = "^\\REGISTRY\\Machine\\(.*)$"
     
      Set colMatches = objRegExp.Execute(strDevice)
     
      For Each objMatch In colMatches
        strKey = objMatch.SubMatches(0)
      Next
     
      If (strKey = "") Then Exit Function
     
      strValue = "Acceleration.Level"
     
      intErr = objReg.GetDWORDValue(HKLM, strKey, strValue, intAccelValue)
     
      If (intErr = 0) Then
        GetAccelerationSetting = intAccelValue
      Else
        GetAccelerationSetting = 0
      End If
    End Function
    EE Thread is here :

    http://www.experts-exchange.com/Prog..._21646882.html

    Only thing with this code is that you would after doing this have to some how have to re initliziaze the display driver or something to that effect , short of that reboot it as per the comment here from EE:

    Note that if you modify the code to SET the acceleration value, you will probably have to reboot the computer to get the changes to take effect. Most of the time, updating the registry directly does not force windows to reinitialize whatever component you're changing (the way updating this setting through the Control Panel does).

  3. #3

    Join Date
    Jan 2006
    Posts
    143
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: Disabling/re-enabling hardware graphics acceleration

    Fantastic, thanks for the swift response, I'll test it out on my system

  4. #4

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,705
    Thank Post
    3,239
    Thanked 1,045 Times in 967 Posts
    Rep Power
    363

    Re: Disabling/re-enabling hardware graphics acceleration

    If you alter it or get it to work , would be nice to get a post back and let me know what happens. I did a little bit of testing but never really got it to work without a reboot so would be nice to get an updated version that can do it on the fly

  5. #5

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,705
    Thank Post
    3,239
    Thanked 1,045 Times in 967 Posts
    Rep Power
    363

    Re: Disabling/re-enabling hardware graphics acceleration

    Here is the original version that was posted back with ( a lot harder to implement so your better off sticking with the first one I posted ) but just so that you get the table to see how it is done to set the value , I thought this info would be handy :


    Looks pretty straightforward. From an API perspective, all you need to do is modify a couple of INI files and registry values. The trick is learning the combinations of values which make up the 4 valid conditions (copying and pasting from the PAQ's pseudo-code):


    Lets define 3 parameters:

    1) P_SAFEMODE
    -------------
    INIFILE = WIN.INI
    SECTION = Windows
    KEY = SafeMode

    REGKEY = 0
    REGVALUE= 0

    MIN = 0
    MAX = 2
    DEFAULT = 0

    2) P_ADVANCED
    -------------
    INIFILE = SYSTEM.INI
    SECTION = Display
    KEY = Mmio

    REGKEY = Display\Settings
    REGVALUE= Advanced

    MIN = 0
    MAX = 1
    DEFAULT = 1

    3) P_SWCURSOR
    -------------
    INIFILE = SYSTEM.INI
    SECTION = Display
    KEY = SwCursor

    REGKEY = Display\Settings
    REGVALUE= SwCursor

    MIN = 0
    MAX = 1
    DEFAULT = 0

    ...

    Here is the second part of the answer - how to set hardware acceleration setting.

    Accel value
    0 1 2 3 Default (3)
    ----------------------------------
    safeMode 2 1 0 0 0
    isAdvanced 0 0 1 1 1
    isSwCursor 1 1 1 0 0

    The "Accel value" is a made up number, used to define the 4 valid conditions. For each Accel value, you need to set the proper combination of safeMode, isAdvanced, and isSwCursor in their respective INI file / registry key. The VB code for this will look nearly identical to the C code in the PAQ (other than syntax differences.... Class versus typedef struct, etc). Unfortunately I don't have time to write and test the VB version right now. Note that this PAQ may be only applicable for Win9x or NT4 systems... it's fairly old, and I noticed in my Display control panel (on a Windows XP system) that there were actually SIX options on the Acceleration slider, not 4. Even if you convert the algorithm to VB as-is, it may no longer be appropriate for recent operating systems.

    Obviously you will have to alter the vbscript to your needs but its a reasonable start

    At least I thought so

  6. #6

    Join Date
    Jan 2006
    Posts
    143
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: Disabling/re-enabling hardware graphics acceleration

    Thanks very much for your help on this wet and grey half term Monday

    I have used the script to set and report on various levels of hardware acceleration, all well and good.

    The reinitialisation is a bit trickier, I agree. I cast around fora means of testing the level of acceleration without looking at the registry or the advanced display settings tabs (which just report the reg settings) and gave dxdiag a go.

    I used the test buttons on the Display tab, and the 3D test failed on all 3 stages when I had disabled acceleration. I re-enabled using the script, then ran it again. It failed on stage 1 but succeeded on stages 2 and 3, so suspect it must have reinitialised somewhere in there. I haven't used dxdiag before, so need to work out if I can use it programatically in some way to do the reinitialisation for me.

    Will report back!

    Thanks

  7. #7

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,705
    Thank Post
    3,239
    Thanked 1,045 Times in 967 Posts
    Rep Power
    363

    Re: Disabling/re-enabling hardware graphics acceleration

    Here is a step by step on how it works:

    I have tested the solution to work on Windows 2000 with a Matrox G450 DH and on Windows XP with some ATI graphics adapter. No warranty, but it looks like it is a general solution for XP/2K.

    It works as follows:

    (1) Find out the position of the current video device, information on this may be found in the registry, here:
    \\HKLM\HARDWARE\DEVICEMAP\VIDEO\Device\Video0
    There you will find a LPSTR type of entry, pointing to a registry key for the current video device, e.g.
    "\Registry\Machine\System\ControlSet001\Services\G 400\Device0"
    (2) Parse that string, replacing "\Registry\Machine" with HKLM (HKEY_LOCAL_MACHINE) and open the corresponding registry key,
    (3) Look for a DWORD value "Acceleration.Level". If the value does not exists, hardware acceleration is set to "Full". Otherwise, "Acceleration.Level" may be one of 0x1 to 0x5, 0x5 meaning "No Acceleration", and 0x1 meaning "All but cursor acceleration" (see "Extended Display Settings").
    (4) Set the desired acceleration level, or delete the entry to set "Full" acceleration mode.
    (5) Let Windows reload the display settings by using the following code:

    DEVMODE devMode;
    BOOL success = ::EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devMode);
    if (success == TRUE)
    {
    LONG result = ::ChangeDisplaySettings(&devMode, CDS_RESET);
    printf("ChangeDisplaySettings() returned: %d\n", result);
    }

    First, the current display settings are loaded into the devMode variable, and then, the displayed is forced to perform a reset; at this occasion, the "Acceleration.Level" value is read out from the registry and the new acceleration level is set.

    Not sure if that helps any with regards to refreshing it.

    From that it looks like its step 5 ( or an altered version of that ) that you need to some how implement in vbs.

    Just so you are aware the code in step 5 is originally in delphi ( not sure what version ) but that will defintly help when it comes to trying to port it to vbs, if thats even possible.

    Maybe ICT NUT or someone like that can help with that part

  8. #8

    john's Avatar
    Join Date
    Sep 2005
    Location
    London
    Posts
    10,507
    Thank Post
    1,492
    Thanked 1,050 Times in 919 Posts
    Rep Power
    302

    Re: Disabling/re-enabling hardware graphics acceleration

    Just a handy hint RE Pro Desktop, don't forget to complete and Extrusion as an Administrator before you let the kids use it otherwise it will just crash and burn when they try and extrude. You only need to draw a shape, hit the Extrude button on the bottom taskbar and drag the yellow square up to make it a cube / cylinder (or whatever 3D shape it becomes from your flat shape) and then hit ok to make it stick, then anyone can extrude etc.

  9. #9

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,705
    Thank Post
    3,239
    Thanked 1,045 Times in 967 Posts
    Rep Power
    363

    Re: Disabling/re-enabling hardware graphics acceleration

    really stupid thought here .... but what about just for testing purposes if you used F5 after you use that script and then tried dxdiag to see if it gets the graphics card to re initialize itself after you press F5.

    If it does then you just need to figure out how to get the screen to refresh without using send keys, might be able to get iexplorer to do it for you ( possibly ) not sure on that though.

SHARE:
+ Post New Thread

Similar Threads

  1. Graphics Tablets
    By enjay in forum Hardware
    Replies: 0
    Last Post: 27th April 2007, 02:43 PM
  2. 3d Graphics Question
    By rama1712 in forum Windows
    Replies: 1
    Last Post: 14th November 2006, 10:35 AM
  3. Graphics Software
    By MrChips in forum Educational Software
    Replies: 1
    Last Post: 27th November 2005, 06:58 PM
  4. Replies: 4
    Last Post: 29th June 2005, 12:43 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •