所以,我想创建服务。我的程序需要作为服务工作,而不需要处理。我在互联网上找到并编辑了以下代码:
#define rootkitname "myrootkit"
SC_HANDLE hSCManager;
hSCManager=OpenSCManager(NULL, NULL,SC_MANAGER_CREATE_SERVICE);
LPVTSTR rootkpath;
rootkpath="C:\Users\Admin\Desktop\Blocker\Project1.exe";
SC_HANDLE hManager,hService; hService=CreateService(hManager,rootkitname,rootkitname,SERVICE_ALL_ACCESS,SER VICE_KERNEL_DRIVER, SERVICE_BOOT_START,SERVICE_ERROR_NORMAL, \rootkpath,NULL,NULL,NULL, NULL,NULL,NULL);
StartService(hService,NULL,NULL);
此代码创建服务,但是有错误。在Builder6中,我有此错误:
[C++ Error] Unit1.cpp(60): E2451 Undefined symbol 'LPVTSTR'
[C++ Error] Unit1.cpp(60): E2379 Statement missing ;
[C++ Error] Unit1.cpp(61): E2451 Undefined symbol 'rootkpath'
[C++ Error] Unit1.cpp(63): E2206 Illegal character '\' (0x5c)
[C++ Error] Unit1.cpp(63): E2227 Extra parameter in call to __stdcall CreateServiceA(void *,const char *,const char *,unsigned long,unsigned long,unsigned long,unsigned long,const char *,const char *,unsigned long *,const char *,const char *,const char *)
请帮帮我。我的应用程序的目标是:用户无法从任务管理器中关闭我的程序。
答案 0 :(得分:1)
LPVTSTR
不是问题,谷歌建议LPCTSTR
(不知道这是否正确)。 C字符串中的反斜杠必须加倍,因此rootkpath="C:\\Users\\Admin\\...
在对CreateService
-\rootkpath
的呼叫中,应该只是rootkpath
,最后删除NULL
中的一个,您的数目太多了。