그래서 전망에 대한 이벤트 ID를 중지하고/닫기, AddIns를 설치 한 경우 ID : 45를 사용하여 시작을 감지 할 수 있지만 여전히 닫기 이벤트가 없습니다!
Outlook 시작/종료에서 이벤트를 가져 오는 유일한 방법은 Outlook 시작 또는 종료 이벤트에서 실행되는 Outlook AddIn 또는 VBA-Makro를 통해 직접 시작/종료하는 것입니다. 아웃룩 추가 기능에 대한
샘플 : (
public partial class ThisAddIn
{
private EventLog log = null;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
log = new EventLog();
log.Source = "OutlookAddIn";
log.Log = "Application";
log.WriteEntry("Outlook start", EventLogEntryType.Information, 1);
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
if (log != null)
{
log.WriteEntry("Outlook stop", EventLogEntryType.Information, 0);
}
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
UPDATE
I've 자신에 의해 VBA 솔루션을 시도하고 다음 코드를 사용하여 모듈을 만들고
;-) 근무 Source)
Option Explicit
Declare Function RegisterEventSource Lib "advapi32.dll" Alias _
"RegisterEventSourceA" (ByVal lpUNCServerName As String, _
ByVal lpSourceName As String) As Long
Declare Function DeregisterEventSource Lib "advapi32.dll" (_
ByVal hEventLog As Long) As Long
Declare Function ReportEvent Lib "advapi32.dll" Alias _
"ReportEventA" (_
ByVal hEventLog As Long, ByVal wType As Integer, _
ByVal wCategory As Integer, ByVal dwEventID As Long, _
ByVal lpUserSid As Any, ByVal wNumStrings As Integer, _
ByVal dwDataSize As Long, plpStrings As Long, _
lpRawData As Any) As Boolean
Declare Function GetLastError Lib "kernel32"() As Long
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (_
hpvDest As Any, hpvSource As Any, _
ByVal cbCopy As Long)
Declare Function GlobalAlloc Lib "kernel32" (_
ByVal wFlags As Long, _
ByVal dwBytes As Long) As Long
Declare Function GlobalFree Lib "kernel32" (_
ByVal hMem As Long) As Long
Public Const EVENTLOG_SUCCESS = 0
Public Const EVENTLOG_ERROR_TYPE = 1
Public Const EVENTLOG_WARNING_TYPE = 2
Public Const EVENTLOG_INFORMATION_TYPE = 4
Public Const EVENTLOG_AUDIT_SUCCESS = 8
Public Const EVENTLOG_AUDIT_FAILURE = 10
Public Sub LogNTEvent(sString As String, iLogType As Integer, _
iEventID As Long)
Dim bRC As Boolean
Dim iNumStrings As Integer
Dim hEventLog As Long
Dim hMsgs As Long
Dim cbStringSize As Long
hEventLog = RegisterEventSource("", Application.Name)
cbStringSize = Len(sString) + 1
hMsgs = GlobalAlloc(&H40, cbStringSize)
CopyMemory ByVal hMsgs, ByVal sString, cbStringSize
iNumStrings = 1
If ReportEvent(hEventLog, _
iLogType, 0, _
iEventID, 0&, _
iNumStrings, cbStringSize, _
hMsgs, hMsgs) = 0 Then
MsgBox GetLastError()
End If
Call GlobalFree(hMsgs)
DeregisterEventSource (hEventLog)
End Sub
는 그리고 이것은 당신의 OutlookSessionApplication 파일이 (how to get there)과 같아야하고 makros을 허용하는 것을 잊지 또는 하나 피고측은 "outlookspy";-)
Private Sub Application_Quit()
Call LogNTEvent("OUTLOOK QUIT", _
EVENTLOG_INFORMATION_TYPE, 1000)
End Sub
Private Sub Application_Startup()
Call LogNTEvent("OUTLOOK START", _
EVENTLOG_INFORMATION_TYPE, 1001)
End Sub
Outlook 시작 이벤트가 없습니다. Outlook-AddIns가 설치된 경우이 이벤트 (ID : 45)를 사용하여 시작을 감지 할 수 있습니다 ... – makim
@sine 예 AddIns가 Outlook에 설치되어 있고 해당 이벤트 ID를 가져올 수 있습니다. 이벤트 ID 또는 다른 방법으로 Outlook이 닫히면 pst가 백업을 종료해야합니다 ... –
추가 기능이있는 경우 Outlook20010의 종료를 감지하기 위해'Event (id : 52)'를 사용할 수 있습니다. 그게 종료보다 500ms가 걸립니다 : P –