I have an appointment with OutLook.

Source: Internet
Author: User
Our company implements an elastic work system, which can work 8 hours a day.
My memory is not very good. I always forget what I came to work. So I thought about how to develop such a small tool.
This is not the case. I just worked too busy these days and made a small tool.
When you log on to the system, it determines whether you are logging on to the system for the first time today. If so
Send an appointment eight hours later ". In this way, OutLook will remind you that you should leave work.
This tool is divided into three parts.
1. Windows logon event monitor, which is a dll file. It is developed in C. Some source code is as follows: _ Declspec (dllexport) void _ stdcall testlogon (DWORD unknow)
{
// Find the file login. log in the temporary directory,
// 1. If it is found, view the file modification time
// 2. If no value exists, an empty file is created and a program for creating OutLook Appointment is executed.
Char tempPath [80];
Char fileName [] = "login. log ";
Int I = 0;
DWORD len;
FILE * FileHandle;
Struct tm * newtime;
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory (& si, sizeof (si ));
Si. cb = sizeof (si );
ZeroMemory (& pi, sizeof (pi ));
ZeroMemory (tempPath, sizeof (tempPath ));
Len = GetTempPath (sizeof (tempPath), tempPath );
For (I = 0; I <sizeof (fileName); I ++)
{
TempPath [I + len] = fileName [I];
}

If (FileExists (tempPath) = 1)
{
//
Printf ("login1 ");
Newtime = GetFileMofiedTime (tempPath );
If (IsToday (* newtime) = 0)
{
// Free (newtime );
Remove (tempPath );
}
Else
{
// Free (newtime );
Return 1;
}
}
Printf ("login2 ");
// Sleep (1, 1000 );
// If (FileExists (tempPath) = 1)
//{
// FileHandle = fopen (tempPath, "r + ");
//}
// Else
{
FileHandle = fopen (tempPath, "w + ");
}
If (FileHandle! = NULL)
{
Fwrite (".", 1, 1, FileHandle );
Fclose (FileHandle );
}
// MessageBox (NULL, "login3", tempPath, MB_ OK );
If (! CreateProcess (NULL, "NewAppoint.exe", NULL, NULL, FALSE, 0, NULL, NULL, & si, & pi ))
{
Printf ("login4"); //, tempPath, MB_ OK );
Return 1;
}
Else
{
Printf ("login5"); // "login5", tempPath, MB_ OK );
// Wait until child process exits.
WaitForSingleObject (pi. hProcess, INFINITE );
// Close process and thread handles.
CloseHandle (pi. hProcess );
CloseHandle (pi. hThread );
}
Return 1;
}

Second, register the monitor dll with the following registry file.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon \ y Y \ GoHome]
"DLLName" = "LogIn. dll"
"Logon" = "testlogon"
"Impersonate" = dword: 00000001
"Asynchronous" = dword: 00000001
"Unlock" = "testlogon"

Third: the program that sends an appointment to OutLook. The source file is developed in C. As follows: Microsoft. Office. Interop. Outlook. ApplicationClass outLookApp = new Microsoft. Office. Interop. Outlook. ApplicationClass ();
AppointmentItemClass appointItem = (AppointmentItemClass) outLookApp. CreateItem (OlItemType. olAppointmentItem );
// AppointItem
AppointItem. Location = "RPC ";
AppointItem. Subject = "It's time to go home ";
AppointItem. Importance = OlImportance. olImportanceNormal;
AppointItem. Body = "Shark Xu .";
AppointItem. BusyStatus = OlBusyStatus. olOutOfOffice;
AppointItem. Duration = 1;
AppointItem. Start = System. DateTime. Now. AddHours (8.0 );
AppointItem. ReminderMinutesBeforeStart = 1;
AppointItem. sensiti.pdf = olsensiti.pdf. olNormal;

AppointItem. Save ();

I also made an installation file, which is a batch processing file Copy Login. dll % SystemRoot % \ System32 \
Copy newAppoint.exe % SystemRoot % \ System32 \
Regedit/s GoHome. reg


Full download (including all source files and compiled programs)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.