資源簡介
將jar包可執(zhí)行文件注冊為windows服務(wù)的工具,方便,簡單,易操作

代碼片段和文件信息
#include?“nssm.h“
#include?
extern?imports_t?imports;
/*?Open?Policy?object.?*/
int?open_lsa_policy(LSA_HANDLE?*policy)?{
??LSA_object_ATTRIBUTES?attributes;
??ZeroMemory(&attributes?sizeof(attributes));
??NTSTATUS?status?=?LsaOpenPolicy(0?&attributes?POLICY_ALL_ACCESS?policy);
??if?(status)?{
????print_message(stderr?NSSM_MESSAGE_LSAOPENPOLICY_FAILED?error_string(LsaNtStatusToWinError(status)));
????return?1;
??}
??return?0;
}
/*?Look?up?SID?for?an?account.?*/
int?username_sid(const?TCHAR?*username?SID?**sid?LSA_HANDLE?*policy)?{
??LSA_HANDLE?handle;
??if?(!?policy)?{
????policy?=?&handle;
????if?(open_lsa_policy(policy))?return?1;
??}
??/*
????LsaLookupNames()?can‘t?look?up?.\username?but?can?look?up
????%COMPUTERNAME%\username.??ChangeServiceConfig()?writes?.\username?to?the
????registry?when?%COMPUTERNAME%\username?is?a?passed?as?a?parameter.??We
????need?to?preserve?.\username?when?calling?ChangeServiceConfig()?without
????changing?the?username?but?expand?to?%COMPUTERNAME%\username?when?calling
????LsaLookupNames().
??*/
??TCHAR?*expanded;
??unsigned?long?expandedlen;
??if?(_tcsnicmp(_T(“.\\“)?username?2))?{
????expandedlen?=?(unsigned?long)?(_tcslen(username)?+?1)?*?sizeof(TCHAR);
????expanded?=?(TCHAR?*)?HeapAlloc(GetProcessHeap()?0?expandedlen);
????if?(!?expanded)?{
??????print_message(stderr?NSSM_MESSAGE_OUT_OF_MEMORY?_T(“expanded“)?_T(“username_sid“));
??????if?(policy?==?&handle)?LsaClose(handle);
??????return?2;
????}
????memmove(expanded?username?expandedlen);
??}
??else?{
????TCHAR?computername[MAX_COMPUTERNAME_LENGTH?+?1];
????expandedlen?=?_countof(computername);
????GetComputerName(computername?&expandedlen);
????expandedlen?+=?(unsigned?long)?_tcslen(username);
????expanded?=?(TCHAR?*)?HeapAlloc(GetProcessHeap()?0?expandedlen?*?sizeof(TCHAR));
????if?(!?expanded)?{
??????print_message(stderr?NSSM_MESSAGE_OUT_OF_MEMORY?_T(“expanded“)?_T(“username_sid“));
??????if?(policy?==?&handle)?LsaClose(handle);
??????return?2;
????}
????_sntprintf_s(expanded?expandedlen?_TRUNCATE?_T(“%s\\%s“)?computername?username?+?2);
??}
??LSA_UNICODE_STRING?lsa_username;
#ifdef?UNICODE
??lsa_username.Buffer?=?(wchar_t?*)?expanded;
??lsa_username.Length?=?(unsigned?short)?_tcslen(expanded)?*?sizeof(TCHAR);
??lsa_username.MaximumLength?=?lsa_username.Length?+?sizeof(TCHAR);
#else
??size_t?buflen;
??mbstowcs_s(&buflen?NULL?0?expanded?_TRUNCATE);
??lsa_username.MaximumLength?=?(unsigned?short)?buflen?*?sizeof(wchar_t);
??lsa_username.Length?=?lsa_username.MaximumLength?-?sizeof(wchar_t);
??lsa_username.Buffer?=?(wchar_t?*)?HeapAlloc(GetProcessHeap()?0?lsa_username.MaximumLength);
??if?(lsa_username.Buffer)?mbstowcs_s(&buflen?lsa_username.Buffer?lsa_username.MaximumLength?expanded?_TRUNCATE);
??else?{
????if?(policy?==?&handle)?LsaClose(handle);
????HeapFree(GetProcessHeap()?0?expanded);
????print_message(stderr?NSSM_MESSAGE_OUT_OF_MEMORY?_T(“LSA_UNICODE_STRING“)?_T(“username_sid()“));
????return?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-06-29?20:36??nssm-2.23\
?????文件????????8183??2014-06-29?20:34??nssm-2.23\ChangeLog.txt
?????文件???????28339??2014-06-29?20:34??nssm-2.23\README.txt
?????目錄???????????0??2014-06-29?20:36??nssm-2.23\src\
?????文件???????11351??2014-06-29?20:28??nssm-2.23\src\account.cpp
?????文件?????????904??2014-06-29?20:28??nssm-2.23\src\account.h
?????文件????????5637??2014-04-15?07:15??nssm-2.23\src\console.cpp
?????文件?????????105??2014-01-27?00:27??nssm-2.23\src\console.h
?????文件????????4540??2014-04-02?05:32??nssm-2.23\src\env.cpp
?????文件?????????329??2014-04-02?05:32??nssm-2.23\src\env.h
?????文件????????3744??2014-01-28?06:38??nssm-2.23\src\event.cpp
?????文件?????????284??2014-01-02?08:15??nssm-2.23\src\event.h
?????文件???????49516??2014-06-29?20:28??nssm-2.23\src\gui.cpp
?????文件?????????405??2013-12-25?02:23??nssm-2.23\src\gui.h
?????文件????????3059??2014-06-29?20:28??nssm-2.23\src\imports.cpp
?????文件?????????881??2014-01-30?04:41??nssm-2.23\src\imports.h
?????文件???????21612??2014-01-27?00:25??nssm-2.23\src\io.cpp
?????文件????????1387??2014-01-27?00:25??nssm-2.23\src\io.h
?????文件??????149764??2014-05-17?04:28??nssm-2.23\src\messages.mc
?????文件????????6994??2014-02-07?05:41??nssm-2.23\src\nssm.cpp
?????文件????????4161??2014-01-30?04:41??nssm-2.23\src\nssm.h
?????文件???????32040??2013-12-22?01:16??nssm-2.23\src\nssm.ico
?????文件???????64808??2014-05-26?07:14??nssm-2.23\src\nssm.rc
?????文件????????1243??2013-12-22?01:16??nssm-2.23\src\nssm.sln
?????文件???????17272??2014-01-30?04:41??nssm-2.23\src\nssm.vcproj
?????文件???????10754??2014-01-28?06:38??nssm-2.23\src\process.cpp
?????文件?????????635??2014-01-28?06:38??nssm-2.23\src\process.h
?????文件???????30316??2014-03-03?05:57??nssm-2.23\src\registry.cpp
?????文件????????2919??2014-03-03?05:57??nssm-2.23\src\registry.h
?????文件????????3226??2014-03-03?05:57??nssm-2.23\src\resource.h
?????文件???????71167??2014-06-29?20:28??nssm-2.23\src\service.cpp
............此處省略8個文件信息
- 上一篇:Java實現(xiàn)B+Tree
- 下一篇:ATM_java課程設(shè)計
評論
共有 條評論