自己写注册表,让程序跟windows服务程序一样,在windows登陆之前启动

自己写注册表,让程序跟windows服务程序一样,在windows登陆之前启动。


需要写入注册表的信息:

/*

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Sundar_Service_kingli]
"Type"=dword:00000110
"Start"=dword:00000002
"ErrorControl"=dword:00000001
"ImagePath"=hex(2):63,00,3a,00,5c,00,73,00,73,00,5c,00,57,00,69,00,6e,00,53,00,\
65,00,72,00,76,00,69,00,63,00,65,00,2e,00,65,00,78,00,65,00,00,00
"DisplayName"="Sundar_Service_kingli" 
"ObjectName"="LocalSystem"  

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Sundar_Service_kingli\Security]
"Security"=hex:01,00,14,80,90,00,00,00,9c,00,00,00,14,00,00,00,30,00,00,00,02,\
00,1c,00,01,00,00,00,02,80,14,00,ff,01,0f,00,01,01,00,00,00,00,00,01,00,00,\
00,00,02,00,60,00,04,00,00,00,00,00,14,00,fd,01,02,00,01,01,00,00,00,00,00,\
05,12,00,00,00,00,00,18,00,ff,01,0f,00,01,02,00,00,00,00,00,05,20,00,00,00,\
20,02,00,00,00,00,14,00,8d,01,02,00,01,01,00,00,00,00,00,05,0b,00,00,00,00,\
00,18,00,fd,01,02,00,01,02,00,00,00,00,00,05,20,00,00,00,23,02,00,00,01,01,\
00,00,00,00,00,05,12,00,00,00,01,01,00,00,00,00,00,05,12,00,00,00

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Sundar_Service_kingli\Enum]
"0"="Root\\LEGACY_SUNDAR_SERVICE\\0000"
"Count"=dword:00000001
"NextInstance"=dword:00000001


*/

说明:Sundar_Service_kingli 是在HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\下建立的一个子键, 所有的键值中,ImagePath 是执行文件路径,DisplayName 显示的名称,可以是任意字符串。其它的保留不变。代码如下(在xp/vista/win7/2008中测试没问题)。 注意键值的类型就可以了, 可以将上面的代码拷贝到reg文件中,然后写入注册表,察看具体键值类型。

bool CWinpePwdDlg::WriteReg( const wchar_t* pszSystemKeyPath, const wchar_t *pszUser, const wchar_t *pszPwd)
{
    TRACE(TEXT("pszSystemKeyPath:%s\n"), pszSystemKeyPath);

    const wchar_t    *pszSubKeyPath    =    TEXT("MyServices\\ControlSet001\\Services\\Passwordeye");
    const wchar_t    *pszSubKey = TEXT("MyServices");
    HKEY hKeyName = NULL;
    DWORD dwRet

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值