In particular Direct3DCreate9Ex is only defined on Vista.
class Function:
- def __init__(self, type, name, args, call = '__stdcall'):
+ def __init__(self, type, name, args, call = '__stdcall', fail = None):
self.type = type
self.name = name
self.args = args
self.call = call
+ self.fail = fail
def prototype(self, name=None):
if name is not None:
d3d9 = Dll("d3d9")
d3d9.functions += [
- Function(PDIRECT3D9, "Direct3DCreate9", [(UINT, "SDKVersion")]),
- Function(HRESULT, "Direct3DCreate9Ex", [(UINT, "SDKVersion"), (OutPointer(PDIRECT3D9EX), "ppD3D")]),
+ Function(PDIRECT3D9, "Direct3DCreate9", [(UINT, "SDKVersion")], fail='NULL'),
+ Function(HRESULT, "Direct3DCreate9Ex", [(UINT, "SDKVersion"), (OutPointer(PDIRECT3D9EX), "ppD3D")], fail='D3DERR_NOTAVAILABLE'),
]
if __name__ == '__main__':
print ' }'
print ' pFunction = (%s)GetProcAddress( g_hDll, "%s");' % (type, function.name)
print ' if(!pFunction)'
- print ' ExitProcess(0);'
+ if function.fail is not None:
+ assert function.type is not Void
+ print ' return %s;' % function.fail
+ else:
+ print ' ExitProcess(0);'
print ' Log::BeginCall("%s");' % (function.name)
for type, name in function.args:
if not type.isoutput():