title: How to call the function which is in another DLL ? (Win7/VB6.0)
body: <p>I'd like to call a function (let's say this is "foo") in a DLL (let's say this is "DLL_A") from another DLL (let's say this is "DLL_B"). Would you tell me how to do this ?</p>
  
  <p>I was able to call the "foo" in "DLL_A" by using declare function as follows.</p>
  
  <pre><code>'standard module
      Declare Function foo Lib "Dll_A.dll" _
       (ByRef val1 As Any, ByVal val2 As Long, _
        ByVal val3 As Long, ByVal val4 As Long, _
   　   ByRef val5 As Any) As Long
  
  'form
      return = foo(val1, val2, val3, val5, val6)
  </code></pre>
  
  <p>Then, I made "Dll_B" by using ActiveX Dll of Visual Basic 6.0. (I used the code below as reference.) "DLL_B" is as follows.</p>
  
  <pre><code>'/*******************************************************************
  '/*     DLL_B
  '/*******************************************************************
  Private Function bar(val1 As Long, val2 As Long, val3 As Long, val4 As Long, val5 As L        ong)
  On Error Resume Next
  'We're going to call an API-function, without declaring it!
  Dim lb As Long, pa As Long
  'map 'user32' into the address space of the calling process.
  lb = LoadLibrary("Dll_A")
  'retrieve the address of 'SetWindowTextA'
  pa = GetProcAddress(lb, "foo")
  'Call the SetWindowTextA-function
  CallWindowProc pa, ByVal val1, ByVal val2, ByVal val3, ByVal val4, ByVal val5
  'unmap the library's address
  FreeLibrary lb
  End Function
  </code></pre>
  
  <p>The code, which I used as reference is as follows.</p>
  
  <pre><code>'/*******************************************************************
  '/*     The code which I used as reference. 
  '/*******************************************************************
  Create a New project And add this code To Form1
  Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
  Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal     lpLibFileName As String) As Long
  Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal     lpProcName As String) As Long
  Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal   lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Any, ByVal wParam As Any, ByVal   lParam As Any) As Long
  
  Private Sub Form_Load()
  On Error Resume Next
  'We're going to call an API-function, without declaring it!
  Dim lb As Long, pa As Long
  'map 'user32' into the address space of the calling process.
  lb = LoadLibrary("user32")
  'retrieve the address of 'SetWindowTextA'
  pa = GetProcAddress(lb, "SetWindowTextA")
  'Call the SetWindowTextA-function
  CallWindowProc pa, Me.hWnd, "Hello !", ByVal 0&amp;, ByVal 0&amp;
  'unmap the library's address
  FreeLibrary lb
  End Sub
  </code></pre>
  
  <p>I called the "bar" by using declare function in the same way as "DLL_A" as follows.</p>
  
  <pre><code>'standard module
  Declare Function bar Lib "Dll_B.dll" _
  (ByRef val1 As Any, ByVal val2 As Long, _
  ByVal val3 As Long, ByVal val4 As Long, _
  ByRef val5 As Any) As Long
  
  'form
  return = bar(val1, val2, val3, val4, val5)
  </code></pre>
  
  <p>But I execute this code, the following error displays.</p>
  
  <blockquote>
    <p><em>Run-time error '453' Can't find DLL entry point "bar" in "DLL_B"</em></p>
  </blockquote>
  
  <p>I tried to call "bar" as follows, but the error displays as well.</p>
  
  <pre><code>Dim objB As Object
  set objB = CreateObject("Project1.Class1")
  call objB.bar()
  set objB = Nothing
  </code></pre>
  
  <p>After I registered the "DLL_B" with the registry, the error still displays.</p>
  
  <p>Please tell me the solution strategy or give me a clue. </p>