我用标准c作了一个标准的系统服务,当时我不了解如何将它注册的windows系统服务里!
请教高手帮忙??
请教高手帮忙??
解决方案 »
- 新手弱弱的问一下,CWebBrowser2这个类怎么用?
- 在VS2005中能用的界面库有哪些?
- 请教http中用post传送数据的格式!
- 请问 这个段vc语句 什么意思,最好能翻译成delphi 的 或者汉字解释也可以的,谢谢了
- 如何編程实现导出Foxmail里的邮件?给出思路者也有分!!!
- 讨论一下:程序员改行做安利是否可行?
- ADO+事务处理是怎么写的呢?我基本没有查到事务处理的VC的写法??(谢了先)
- 大家都用Vc做些什么就用呢?
- 各位高手帮忙:重新启动的程序如何写
- 能正常调试的一个程序,为啥加进一句无错的废话就不能调试了?
- 请教大家一个SQL语句的写法!请您多指点指点!谢谢!
- win2000中怎么加载自己的服务
里masterz给出的那个程序是集服务程序与服务管理程序于一身的最简单的代码。
#include <windows.h>
#include <iostream.h>void ErrorHandler(char *s, DWORD err)
{
cout << s << endl;
cout << "Error number: " << err << endl;
ExitProcess(err);
}void main(int argc, char *argv[])
{
SC_HANDLE newService, scm;
if (argc != 4)
{
cout << "Usage:\n";
cout << " install service_name \
service_label executable\n";
cout << " service_name is the \
name used internally by the SCM\n";
cout << " service_label is the \
name that appears in the Services applet\n";
cout << " (for multiple \
words, put them in double quotes)\n";
cout << " executable is the \
full path to the EXE\n\n";
return;
}
// open a connection to the SCM
scm = OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE);
if (!scm) ErrorHandler("In OpenScManager",
GetLastError());
// Install the new service
newService = CreateService(
scm, argv[1], // eg "beep_srv"
argv[2], // eg "Beep Service"
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
argv[3], // eg "c:\winnt\xxx.exe"
0, 0, 0, 0, 0);
if (!newService) ErrorHandler("In CreateService",
GetLastError());
else cout << "Service installed\n";
// clean up
CloseServiceHandle(newService);
CloseServiceHandle(scm);
}