ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Creating a Windows DLL with Visual Basic
Subject:   Is DllMain being Called?
Date:   2006-02-28 07:42:51
From:   EWBJr
Response to: Is DllMain being Called?

You need to add the following to the custom linker Main sub, preferably after the check for Control Panel applet:




'*** change Entry point ******
If MsgBox("Set DllMain as the entry point?", vbYesNo) = vbYes Then
strCmd = Replace(strCmd, "/ENTRY:__vbaS", "/ENTRY:DllMain")
End If


Also, the DllMain function needs to return a long, and its arguments must be called byVal, as follows:



Public Function DllMain(ByVal hInst As Long, ByVal fdwReason As Long, ByVal lpvReserved As Long) As Long


Select Case fdwReason
Case DLL_PROCESS_DETACH
' No per-process cleanup needed
Case DLL_PROCESS_ATTACH
' No per-process initialization needed
DllMain = 1
Case DLL_THREAD_ATTACH
' No per-thread initialization needed
Case DLL_THREAD_DETACH
' No per-thread cleanup needed
End Select


End Function


1 to 1 of 1
  1. Is DllMain being Called?
    2007-09-09 10:02:58  Neounk [View]

1 to 1 of 1