
Originally Posted by
Jacob Roman
Nope. It can't find the DLL entry point NVAPI_Initialize
See my posts above and below that addressing this. You need to call it by pointer obtained from NvAPI_QueryInterface, the one function nvapi.dll exports.
ETA: My code was slightly off. First, it appears nvapi.dll uses cdecl, and names are case sensitive and I had the case wrong.
Code:
Private m_hNV As Long
Private Declare Function nvapi_QueryInterface CDecl Lib "nvapi.dll" (ByVal pfn As Long) As Long
Private Declare Function DispCallFunc Lib "oleaut32.dll" ( _
ByVal pvInstance As Long, _
ByVal FuncAddr As Long, _
ByVal CallConvention As Integer, _
ByVal rtnType As VbVarType, _
ByVal FuncArgsCnt As Long, _
ByRef FuncArgTypes As Any, _
ByRef FuncArgVarAddresses As Any, _
ByRef FuncResult As Any) As Long
Sub Main()
m_hNV = LoadLibrary("nvapi.dll")
Dim lpInit As Long 'NvAPI_Initialize
lpInit = NvAPI_QueryInterface(&H0150E828)
Dim lRet As Variant
DispCalFunc 0, lpInit, CC_CDECL, vbLong, 0, ByVal 0, ByVal 0, lRet
Then the result is CLng(lRet). Forgot VB doesn't do that conversion for you.
So you'll need The trick's CDeclFix addin for VB6 in order for the CDecl keyword to work in the API declare.