Results 1 to 40 of 50

Thread: C++ Created DLL File To Use In VB6

Hybrid View

  1. #1
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,667

    Re: C++ Created DLL File To Use In VB6

    Quote Originally Posted by Jacob Roman View Post
    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.
    Last edited by fafalone; Oct 26th, 2023 at 10:08 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width