Timer control to automate your daily tasks, PACT Timer 98!   Timer Options and Timer Registry Values

Works like a charm!

 

PACT Timer 98 - Works like a charm!

PACT ONE

  

Manage your PC with PACT Ghosts 98!
The Ghosts

Copy and rename in one step: PACT 2ndBackup 98! 2ndBackup
Exceptional Application Launcher - PACT DeskTOP 98! DeskTOP
Jump to Registry Keys, Create Shortcuts to Registry Keys!!! JumpToRegKey
Open System Folders Quicker with PACT Quicky 98! Quicky
Save your Desktop Icon Layout with PACT Save Layout 98! SaveDTLayout
Set File and Date per Shortcut on Folders - PACT SetFileDate 98 SetFileDate
Set the Desktop Icon Text Color and Background Color even to Transparent with PACT SetTextColor 98! SetDTextColor
Position and Size Windows with a click: PACT Set Window Pos 98! SetWindowPos
Shutdown with one click, start backup before. PACT Shutdown 98! Shutdown
Automate your daily tasks with PACT Timer 98! 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

 

 

 

 

  Microsoft Certified Professional
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 Timer Homepage
FAQ Frequently Asked Questions FAQ Frequently Asked Questions
Options and Registry Values 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 Timer Homepage
FAQ Frequently Asked Questions FAQ Frequently Asked Questions
Options and Registry Values Options and Registry Values

 

PACT Top Pages:

Phil's Visual C Tricks Source Code

The PACT Acronym List - more than 700 abbreviations and infos

You can learn typewriting with ten fingers!

Timer 98 schedules your daily tasks

Save your desktop icon layout - SL 98

How to Decode PGP in Outlook 97 with VBA Source Code

49 Ideas of Silence - Reduce the Noise around your PC

  

 

Microsoft Certified Professional
The Man With the Most MCP Titles
 

Editorials

Who is PACT?

E-mail PACT

PACT ONE

 

 

 

PACT Software
"It's not the product that you use, it's the VISION that you share."«

     

Start

Software Articles Know-how Personal
Order License
Feedback

   

Copyright ⌐ 1993-1998 PACT. All rights reserved.