| 发表于:2007-09-07 03:28:393楼 得分:0 |
不知道是不是这个 private const service_kernel_driver = 1 private const service_auto_start = 2 private const service_demand_start = 3 private const service_error_normal = 1 private const sc_manager_create_service = &h2& private const standard_rights_required = &hf0000 private const service_query_config = &h1& private const service_change_config = &h2& private const service_query_status = &h4& private const service_enumerate_dependents = &h8& private const service_start = &h10& private const service_stop = &h20& private const service_pause_continue = &h40& private const service_interrogate = &h80& private const service_user_defined_control = &h100& private const service_all_access = (standard_rights_required or _ service_query_config or _ service_change_config or _ service_query_status or _ service_enumerate_dependents or _ service_start or _ service_stop or _ service_pause_continue or _ service_interrogate or _ service_user_defined_control) private declare function openscmanager _ lib "advapi32 " alias "openscmanagerw " _ (byval lpmachinename as long, byval lpdatabasename as long, _ byval dwdesiredaccess as long) as long private declare function createservice _ lib "advapi32 " alias "createservicew " _ (byval hscmanager as long, byval lpservicename as long, _ byval lpdisplayname as long, byval dwdesiredaccess as long, _ byval dwservicetype as long, byval dwstarttype as long, _ byval dwerrorcontrol as long, byval lpbinarypathname as long, _ byval lploadordergroup as long, byval lpdwtagid as long, _ byval lpdependencies as long, byval lpservicestartname as long, _ byval lppassword as long) as long private declare function deleteservice _ lib "advapi32 " (byval hservice as long) as long private declare function closeservicehandle _ lib "advapi32 " (byval hscobject as long) as long private declare function openservice _ lib "advapi32 " alias "openservicew " _ (byval hscmanager as long, byval lpservicename as long, _ byval dwdesiredaccess as long) as long private declare function startservice lib "advapi32 " _ alias "startservicew " (byval hservice as long, _ byval dwnumserviceargs as long, byval lpserviceargvectors as long) as long private declare function changeserviceconfig2 lib "advapi32 " alias "changeserviceconfig2w " (byval hservice as long, _ byval dwinfolevel as long, lpinfo as any) as long private const service_name = "readsam " private const service_display_name = "readsam " public function loadsys(sys as string) as boolean 'sys最好在系统derivers目录中 dim hscmanager as long, hservice as long hscmanager = openscmanager(0&, 0&, sc_manager_create_service) if hscmanager then '有则运行 hservice = openservice(hscmanager, strptr(service_name), service_start) if hservice then if startservice(hservice, 0, 0) = 0 then loadsys = true end if else '否则新建 hservice = createservice(hscmanager, strptr(service_name), _ strptr(service_display_name), service_all_access, _ service_kernel_driver, _ service_demand_start, service_error_normal, _ strptr(sys), 0&, 0&, 0&, 0&, 0&) if hservice then if startservice(hservice, 0, 0) then loadsys = true end if end if closeservicehandle hservice end if closeservicehandle hscmanager end if end function | | |
|