We've expanded our news coverage and improved our search!
for the latest or search for all things across O'Reilly!
Creating a Windows DLL with Visual Basic
Is DllMain being Called?
Response to: Is DllMain being Called?
I've added this and the entry point is indeed being changed. BUT, when I compile the dll it seems that DllMain is running before the message box in the linkers code. For example I tried this:
Const DLL_PROCESS_DETACH = 0
Const DLL_PROCESS_ATTACH = 1
Const DLL_THREAD_ATTACH = 2
Const DLL_THREAD_DETACH = 3
Public Function DllMain(ByVal hInst As Long, ByVal fdwReason As Long, ByVal lpvReserved As Long) As Long
Select Case fdwReason
Print #1, "This is a test:: Finishing!"
' No per-process cleanup needed
' No per-process initialization needed
Open "test.txt" For Output As #1
Print #1, "This is a test:: Starting!" & vbCrLf
DllMain = 1
' No per-thread initialization needed
' No per-thread cleanup needed
when compiling it makes the test file and writes to it perfectly. When i try to load the dll in my application LoadLibrary returns 0. So I checked the dll in my debugger, everything is fine until any call (for example vbaOpenFile). As soon as it enters any of these calls it crashes. removing any calls and just leaving DllMain = 1. makes it load fine.