Subversion Repositories spk

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
11 cycrow 1
//-----------------------------------------------------------------------------
2
// File: DXUtil.cpp
3
//
4
// Desc: Shortcut macros and functions for using DirectX objects
5
//
6
// Copyright (c) Microsoft Corporation. All rights reserved
7
//-----------------------------------------------------------------------------
8
 
9
#include <tchar.h>
10
 
11
#include "Textures.h"
12
 
13
#include <stdarg.h>
14
 
15
#include "DXUtil.h"
16
 
17
 
18
//-----------------------------------------------------------------------------
19
// Name: DXUtil_GetDXSDKMediaPath()
20
// Desc: Returns the DirectX SDK media path
21
//-----------------------------------------------------------------------------
22
const TCHAR* DXUtil_GetDXSDKMediaPath()
23
{
24
    static TCHAR strNull[2] = {0};
25
    static TCHAR strPath[MAX_PATH + 10];
26
    HKEY  hKey=0;
27
    DWORD type=0, size=MAX_PATH;
28
 
29
    strPath[0] = 0;     // Initialize to NULL
30
 
31
    // Open the appropriate registry key
32
    LONG result = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
33
                                _T("Software\\Microsoft\\DirectX SDK"),
34
                                0, KEY_READ, &hKey );
35
    if( ERROR_SUCCESS != result )
36
        return strNull;
37
 
38
    result = RegQueryValueEx( hKey, _T("DX9D4SDK Samples Path"), NULL,
39
                              &type, (BYTE*)strPath, &size );
40
 
41
    if( ERROR_SUCCESS != result )
42
    {
43
        size = MAX_PATH;    // Reset size field
44
        result = RegQueryValueEx( hKey, _T("DX81SDK Samples Path"), NULL,
45
                                  &type, (BYTE*)strPath, &size );
46
 
47
        if( ERROR_SUCCESS != result )
48
        {
49
            size = MAX_PATH;    // Reset size field
50
            result = RegQueryValueEx( hKey, _T("DX8SDK Samples Path"), NULL,
51
                                      &type, (BYTE*)strPath, &size );
52
 
53
            if( ERROR_SUCCESS != result )
54
            {
55
                RegCloseKey( hKey );
56
                return strNull;
57
            }
58
        }
59
    }
60
 
61
    RegCloseKey( hKey );
62
    lstrcat( strPath, _T("\\Media\\\0") );
63
 
64
    return strPath;
65
}
66
 
67