任务计划实现开机自启动实现


开机自启动有很多种方式 : 注册表实现, 任务计划等等;

这里只介绍用com接口实现对任务计划(win32的API :NetScheduleJobAdd在Win7 上没有效果)

我们用到的是ITaskService interface [Task Scheduler] 接口的一些相关函数,因此对系统有一定的要求:

Requirements

Client : Requires Windows Vista.

Server :Requires Windows Server 2008.

Header :Declared in Taskschd.h.

Library : Use Taskschd.lib.

DLL :Requires Taskschd.dll.

下面开始介绍如何实现对任务计划的一些操作:

首先创建一个名为test的任务计划

然后创建一个win32的控制台程序添加下面两个文件,然后再main函数中实现相关的测试。代码如下:

1. TaskScheduleFun.h

#pragma once
#include <stdio.h>
#include <tchar.h>
// com include
#include <comdef.h>
#include <comutil.h>
// task header include
#include <taskschd.h>
// task lib
#pragma comment(lib, "taskschd.lib")
#pragma comment(lib, "comsupp.lib")
#define _WIN32_DCOM
#define MAX_XMLREAD MAX_PATH*10
// Attentions
// Provide by Vivian
// For all functions as following, you must do TaskScheduleCo
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值