Detect DirectX Version: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Added category links.)
m (Adding new author and category links.)
Line 1: Line 1:
{|align=right
{{PageAuthor|jason379}}
|<small>Author: [[{{ns:2}}:jason379|jason379]] ([[{{ns:3}}:jason379|talk]], [[{{ns:-1}}:Contributions/jason379|contrib]])</small>
 
|}
<br style="clear:both;">
== Description ==
== Description ==
This code will return the DirectX version number on the stack, or zero if DirectX is not installed. The return value is an integer concatonating the major and minor version: "810" for version 8.1, "900" for version 9.0.
This code will return the DirectX version number on the stack, or zero if DirectX is not installed. The return value is an integer concatonating the major and minor version: "810" for version 8.1, "900" for version 9.0.
Line 41: Line 39:
</highlight-nsis>
</highlight-nsis>


[[{{ns:14}}:Other Products Version Detection Functions]]
[[Category:Other Products Version Detection Functions]]

Revision as of 12:05, 24 June 2005

Author: jason379 (talk, contrib)


Description

This code will return the DirectX version number on the stack, or zero if DirectX is not installed. The return value is an integer concatonating the major and minor version: "810" for version 8.1, "900" for version 9.0.

Example

Here is an example of how it can be used:

  Call GetDXVersion
  Pop $R3
  IntCmp $R3 900 +3 0 +3
    MessageBox "MB_OK" "Requires DirectX 9.0 or later."
    Abort

The Function

And here is the code:

  Function GetDXVersion
    Push $0
    Push $1
 
    ReadRegStr $0 HKLM "Software\Microsoft\DirectX" "Version"
    IfErrors noDirectX
 
    StrCpy $1 $0 2 5    ; get the minor version
    StrCpy $0 $0 2 2    ; get the major version
    IntOp $0 $0 * 100   ; $0 = major * 100 + minor
    IntOp $0 $0 + $1
    Goto done
 
    noDirectX:
      StrCpy $0 0
 
    done:
      Pop $1
      Exch $0
  FunctionEnd