PACT ONE

The Ghosts
2ndBackup
DeskTOP
JumpToRegKey
Quicky
SaveDTLayout
SetFileDate
SetDTextColor
SetWindowPos
Shutdown
Timer
Online Articles
Know-How
• Visual C Tricks
• Learn
Typewriting
• A C
R O N Y M S
• Dream
PC
• Link
Collection
• YourWeb.com
Personal


MCSE
MCSD MCT MCSI
PACT supports
• Walker's Watchguard
• Citizens for Cycles
|
All information provided here are subject to change at anytime
without notice. No warranties, no liability, no guaranty for fitness of code.
Timer Homepage
FAQ
Frequently Asked Questions
Options
and Registry Values
Timer Options
There is just one command line option, /s
for silent mode. This causes the Timer to not
show the timer dialog after start.
Timer Registry Values
The values should be self-descriptive, however, here is the description of
all values.
ExeDescription |
Up to 100 characters. |
ExePath |
Up to 255 characters. |
ExeParameters |
Up to 255 characters. |
ExeWorkDir |
Up to 255 characters. |
StartNextDate |
'yyyy/MM/dd HH:mm:ss', 24-hour format, leading zero. |
StartEverySec |
recurring time in seconds, 0 = not recurring (if StartNextDate empty then after
logon takes precedence). |
StartSecAfterBoot |
If not 0, this value will be processed, takes precedence. (boot = launch of
Timer = after logon if in Startup). |
StartActivated |
1 = activated, else deactivated. |
StartDeleteAfter |
1 = delete after starting once, else only deactivate. |
StartWorkingOnly |
1 = recurring on working days only, that is, Monday through Friday, else run
every day. |
StartBell |
1 = play sound on action, else no sound. |
WindowState |
0 Normal, 1 Min, 2 Max, 3 No Activate, 4 Min No Activate, 5 Hidden. |
PriorityLevel |
0 Realtime, 1 High, 2 Normal, 3 Idle. |
Example Registry File
Here's an example Registry file you can simply double-click to import it
into the registry. Copy the following lines and paste them into a new text document. Save
it with the extension *.reg.
REGEDIT4
[HKEY_CURRENT_USER\Software\PACT Software\Timer\myNewTimer]
"ExeDescription"="This is an example reminder"
"ExePath"=""
"ExeParameters"=""
"ExeWorkDir"=""
"StartNextDate"="1998/03/12 10:20:00"
"StartEverySec"=dword:00000000
"StartSecAfterBoot"=dword:00000000
"StartActivated"=dword:00000001
"StartDeleteAfter"=dword:00000000
"StartWorkingOnly"=dword:00000000
"StartBell"=dword:00000001
"WindowState"=dword:00000000
"PriorityLevel"=dword:00000002
Programming to the Registry
If you feel comfortable programming to the registry, you'll certainly want
use the following functions.
Create a new subkey below HKEY_CURRENT_USER\Software\PACT Software\Timer\,
for example HKEY_CURRENT_USER\Software\PACT Software\Timer\MyTimerSet001\. In this key set
all values, or only those you need.
Here is a ready to use C source code
program to do just that. First you find the type definition, second the function to create
a new timer set, third, the function to write it to the registry, and fourth, a function
to execute PacTimer.exe to get the newly added subkey re-checked.
From your Visual Basic
program you can also access the registry by declaring the WINAPI functions RegCreateKeyEx,
RegSetValueEx, and RegCloseKey.
// --- Declarations for PACT Timer 98 -----
#define APPREGKEY ("Software\\PACT Software\\Timer")
typedef struct _TimerSet { // ts set for one timer
information
char SubKeyName[MAX_PATH];
char ExeDescription[101];
// max 100 (+ \0)
char ExePath[MAX_PATH];
char ExeParameters[MAX_PATH];
char ExeWorkDir[MAX_PATH];
char StartNextDate[20];
// 1998/03/12 10:20:00 max 20
(= 19 + \0)
UINT StartEverySec;
UINT StartSecAfterBoot;
DWORD StartActivated;
// default: 1 = yes
DWORD StartDeleteAfter;
// default: 0 = no, only deactivate
DWORD StartWorkingOnly;
// default: 0 = run every day
DWORD StartBell;
// default: 1 = yes, play sound
DWORD WindowState;
// 0-5
default: 0, normal
DWORD PriorityLevel;
// 0-3
default: 2, normal
} TIMERSET;
void main();
BOOL SetTimerSet(TIMERSET *pts);
void StartPacTimer();
// --- Example on how to init and save a new timer -----
// Copyright ⌐ 1993-1998 PACT on all examples and
materials. All rights reserved.
// The examples provided here are NOT guaranteed to work. No warranties, no liability, no
guaranty for fitness of code.
// --- main -----------------------------
void main()
{
TIMERSET ts;
SYSTEMTIME st;
lstrcpy(ts.SubKeyName, "MyTimerSet0001");
lstrcpy(pts->ExeDescription, "Test Timer");
lstrcpy(pts->ExePath, "Notepad.exe");
pts->ExeParameters[0] = '\0';
pts->ExeWorkDir[0] = '\0';
pts->StartEverySec = 0;
pts->StartSecAfterBoot = 0;
pts->StartActivated = 1;
// yes
pts->StartDeleteAfter = 0;
// no
pts->StartWorkingOnly = 0;
// no
pts->StartBell = 1; //
yes
pts->WindowState = 0; //
0-5 default: 0
pts->PriorityLevel = 2; //
0-3 default: 2
GetLocalTime(&st);
st.wMinute += 5;
if(st.wMinute > 59)
{
st.wMinute -= 60;
st.wHour++; // and so on...
}
wsprintf(ts.StartNextDate, "%04i/%02i/%02i %02i:%02i:%02i",
st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
SetTimerSet(&ts); // save to reg
StartPacTimer(); // restart Timer
return;
}
// --- save timer to registry -------------------
BOOL SetTimerSet(TIMERSET *pts)
{
HKEY hkNewKey;
char szFullKeyName[MAX_PATH];
DWORD dwDummy;
DWORD dwReturn;
lstrcpy(szFullKeyName, APPREGKEY);
lstrcat(szFullKeyName, "\\");
lstrcat(szFullKeyName, pts->SubKeyName);
// Open/Create Key for write access
dwReturn = RegCreateKeyEx(HKEY_CURRENT_USER, szFullKeyName, 0, 0,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkNewKey, &dwDummy);
if(ERROR_SUCCESS != dwReturn)
{
SetLastError(dwReturn);
myErr("Error writing to registry! Can not
open application key.");
return FALSE;
}
// Set SZs
RegSetValueEx(hkNewKey, "ExeDescription", 0, REG_SZ, (CONST
BYTE *) pts->ExeDescription, lstrlen(pts->ExeDescription) + 1);
RegSetValueEx(hkNewKey, "ExePath", 0, REG_SZ, (CONST BYTE *)
pts->ExePath, lstrlen(pts->ExePath) + 1);
RegSetValueEx(hkNewKey, "ExeParameters", 0, REG_SZ, (CONST
BYTE *) pts->ExeParameters, lstrlen(pts->ExeParameters) + 1);
RegSetValueEx(hkNewKey, "ExeWorkDir", 0, REG_SZ, (CONST BYTE
*) pts->ExeWorkDir, lstrlen(pts->ExeWorkDir) + 1);
RegSetValueEx(hkNewKey, "StartNextDate", 0, REG_SZ, (CONST
BYTE *) pts->StartNextDate, lstrlen(pts->StartNextDate) + 1);
// Set DWORDs
RegSetValueEx(hkNewKey, "StartEverySec", 0, REG_DWORD, (CONST
BYTE *) &pts->StartEverySec, sizeof(DWORD));
RegSetValueEx(hkNewKey, "StartSecAfterBoot", 0, REG_DWORD,
(CONST BYTE *) &pts->StartSecAfterBoot, sizeof(DWORD));
RegSetValueEx(hkNewKey, "StartActivated", 0, REG_DWORD,
(CONST BYTE *) &pts->StartActivated, sizeof(DWORD));
RegSetValueEx(hkNewKey, "StartDeleteAfter", 0, REG_DWORD,
(CONST BYTE *) &pts->StartDeleteAfter, sizeof(DWORD));
RegSetValueEx(hkNewKey, "StartWorkingOnly", 0, REG_DWORD,
(CONST BYTE *) &pts->StartWorkingOnly, sizeof(DWORD));
RegSetValueEx(hkNewKey, "StartBell", 0, REG_DWORD, (CONST
BYTE *) &pts->StartBell, sizeof(DWORD));
RegSetValueEx(hkNewKey, "WindowState", 0, REG_DWORD, (CONST
BYTE *) &pts->WindowState, sizeof(DWORD));
RegSetValueEx(hkNewKey, "PriorityLevel", 0, REG_DWORD, (CONST
BYTE *) &pts->PriorityLevel, sizeof(DWORD));
RegCloseKey(hkNewKey);
return TRUE;
}
// --- Start PacTimer.exe -----------------
void StartPacTimer()
{
HKEY hKey;
DWORD dwDummy = MAX_PATH;
char pszInstallPath[MAX_PATH] = {0};
char pszProgPath[MAX_PATH] = {0};
char pszTemp[MAX_PATH] = {0};
GetTempPath(MAX_PATH, pszTemp);
// get install path from Registry
if(ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, APPREGKEY, 0,
KEY_QUERY_VALUE, &hKey))
return;
if( ERROR_SUCCESS == RegQueryValueEx(hKey, "InstallPath",
NULL, NULL, (LPBYTE) pszInstallPath, &dwDummy) )
{
lstrcpy(pszProgPath, pszInstallPath);
lstrcat(pszProgPath,
"\\PacTimer.exe");
ShellExecute(NULL, NULL, pszProgPath, NULL,
pszTemp, SW_SHOWNORMAL);
}
RegCloseKey(hKey);
return;
}
// --------------------------------------------
Support
Should you have a question then our software is not perfect. Let us know, we'll make it better.
Timer Homepage
FAQ
Frequently Asked Questions
Options
and Registry Values
|
|