| 一个操作本地或者远程主机服务的小程序 |
|
| 作者:未知 文章来源:网络收集 点击数: 更新时间:2006-3-29 15:22:23
|
//////////////////////////////////////////////////////////////////////////////// // // Enum Service // // File : EnumService.cpp // // // Create by : refdom // Email : refdom@263.net // Home Page : www.opengram.com // // If you modify the code, or add more functions, please email me a copy. // //////////////////////////////////////////////////////////////////////////////// #include "ConnectServer.h" #include #include #include #include
#pragma comment(lib, "Advapi32.lib") #pragma comment(lib, "Mpr.lib")
DWORD g_dwManagerAccess = SC_MANAGER_ALL_ACCESS; DWORD g_dwServiceAccess = SERVICE_ALL_ACCESS;
void ListServices (SC_HANDLE, DWORD); void MyStartService (SC_HANDLE, LPSTR); void MyStopService (SC_HANDLE, LPSTR); void MyViewService (SC_HANDLE, LPSTR); void Usage(char*);
int main(int argc, char* argv[]) { int nRetCode = 0; char szIpc[50] = ""; DWORD dwServiceType; SC_HANDLE schSCManager; LPSTR lpUserName, lpPassword, lpServiceName; NETRESOURCE NET;
if (argc < 2) { Usage(argv[0]); return 0; }
if (argv[1][0] == "/" && strlen(argv[1]) == 2) { switch (tolower(argv[1][1])) { case "l": dwServiceType = SERVICE_WIN32 | SERVICE_DRIVER; break; case "d": dwServiceType = SERVICE_DRIVER; break; case "w": dwServiceType = SERVICE_WIN32; break; case "k": dwServiceType = SERVICE_KERNEL_DRIVER; break; case "f": dwServiceType = SERVICE_FILE_SYSTEM_DRIVER; break; case "o": dwServiceType = SERVICE_WIN32_OWN_PROCESS; break; case "h": dwServiceType = SERVICE_WIN32_SHARE_PROCESS; break; case "r": dwServiceType = -1; break; case "s": case "p": case "v": if (argc < 6 && (argc != 3)) { printf ("Error! Input a service name!\n"); return 0; } else if (argc >[1] [2] [3] [4] [5] 下一页
|
|
[ 收藏此页到: 天天|和讯|博采|ViVi|狐摘|我摘|天极 ] 文章录入:kinda 责任编辑:kinda |
|
上一篇文章: 在桌面建立快捷方式 下一篇文章: Tini 的VC原代码 |
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |