File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\util\jna\Advapi32.java.html

1 /*
2 Copyright (c) 2007 Thomas Boerkel, All Rights Reserved
3
4 Disclaimer:
5 ===========
6 This code is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This code is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15 */
16 package hudson.util.jna;
17
18 import com.sun.jna.Structure;
19 import com.sun.jna.Native;
20 import com.sun.jna.WString;
21 import com.sun.jna.Pointer;
22 import com.sun.jna.win32.StdCallLibrary;
23 import com.sun.jna.ptr.PointerByReference;
24 import com.sun.jna.ptr.IntByReference;
25
26 /**
27 *
28 * @author TB
29 */
30 public interface Advapi32 extends StdCallLibrary {
31 Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class, Options.UNICODE_OPTIONS);
32
33 /**
34 * Retrieves the name of the user associated with the current thread.
35 *
36 * <p>
37 * See http://msdn.microsoft.com/en-us/library/ms724432(VS.85).aspx
38 */
39 boolean GetUserName(char[] buffer, IntByReference lpnSize);
40
41 /*
42 BOOL WINAPI LookupAccountName(
43 LPCTSTR lpSystemName,
44 LPCTSTR lpAccountName,
45 PSID Sid,
46 LPDWORD cbSid,
47 LPTSTR ReferencedDomainName,
48 LPDWORD cchReferencedDomainName,
49 PSID_NAME_USE peUse
50 );*/
51 boolean LookupAccountName(String lpSystemName, String lpAccountName,
52 byte[] Sid, IntByReference cbSid, char[] ReferencedDomainName,
53 IntByReference cchReferencedDomainName, PointerByReference peUse);
54
55 /*
56 BOOL WINAPI LookupAccountSid(
57 LPCTSTR lpSystemName,
58 PSID lpSid,
59 LPTSTR lpName,
60 LPDWORD cchName,
61 LPTSTR lpReferencedDomainName,
62 LPDWORD cchReferencedDomainName,
63 PSID_NAME_USE peUse
64 );*/
65 boolean LookupAccountSid(String lpSystemName, byte[] Sid,
66 char[] lpName, IntByReference cchName, char[] ReferencedDomainName,
67 IntByReference cchReferencedDomainName, PointerByReference peUse);
68
69 /*
70 BOOL ConvertSidToStringSid(
71 PSID Sid,
72 LPTSTR* StringSid
73 );*/
74 boolean ConvertSidToStringSid(byte[] Sid, PointerByReference StringSid);
75
76 /*
77 BOOL WINAPI ConvertStringSidToSid(
78 LPCTSTR StringSid,
79 PSID* Sid
80 );*/
81 boolean ConvertStringSidToSid(String StringSid, PointerByReference Sid);
82
83 /*
84 SC_HANDLE WINAPI OpenSCManager(
85 LPCTSTR lpMachineName,
86 LPCTSTR lpDatabaseName,
87 DWORD dwDesiredAccess
88 );*/
89 Pointer OpenSCManager(String lpMachineName, WString lpDatabaseName, int dwDesiredAccess);
90
91 /*
92 BOOL WINAPI CloseServiceHandle(
93 SC_HANDLE hSCObject
94 );*/
95 boolean CloseServiceHandle(Pointer hSCObject);
96
97 /*
98 SC_HANDLE WINAPI OpenService(
99 SC_HANDLE hSCManager,
100 LPCTSTR lpServiceName,
101 DWORD dwDesiredAccess
102 );*/
103 Pointer OpenService(Pointer hSCManager, String lpServiceName, int dwDesiredAccess);
104
105 /*
106 BOOL WINAPI StartService(
107 SC_HANDLE hService,
108 DWORD dwNumServiceArgs,
109 LPCTSTR* lpServiceArgVectors
110 );*/
111 boolean StartService(Pointer hService, int dwNumServiceArgs, char[] lpServiceArgVectors);
112
113 /*
114 BOOL WINAPI ControlService(
115 SC_HANDLE hService,
116 DWORD dwControl,
117 LPSERVICE_STATUS lpServiceStatus
118 );*/
119 boolean ControlService(Pointer hService, int dwControl, SERVICE_STATUS lpServiceStatus);
120
121 /*
122 BOOL WINAPI StartServiceCtrlDispatcher(
123 const SERVICE_TABLE_ENTRY* lpServiceTable
124 );*/
125 boolean StartServiceCtrlDispatcher(Structure[] lpServiceTable);
126
127 /*
128 SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandler(
129 LPCTSTR lpServiceName,
130 LPHANDLER_FUNCTION lpHandlerProc
131 );*/
132 Pointer RegisterServiceCtrlHandler(String lpServiceName, Handler lpHandlerProc);
133
134 /*
135 SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx(
136 LPCTSTR lpServiceName,
137 LPHANDLER_FUNCTION_EX lpHandlerProc,
138 LPVOID lpContext
139 );*/
140 Pointer RegisterServiceCtrlHandlerEx(String lpServiceName, HandlerEx lpHandlerProc, Pointer lpContext);
141
142 /*
143 BOOL WINAPI SetServiceStatus(
144 SERVICE_STATUS_HANDLE hServiceStatus,
145 LPSERVICE_STATUS lpServiceStatus
146 );*/
147 boolean SetServiceStatus(Pointer hServiceStatus, SERVICE_STATUS lpServiceStatus);
148
149 /*
150 SC_HANDLE WINAPI CreateService(
151 SC_HANDLE hSCManager,
152 LPCTSTR lpServiceName,
153 LPCTSTR lpDisplayName,
154 DWORD dwDesiredAccess,
155 DWORD dwServiceType,
156 DWORD dwStartType,
157 DWORD dwErrorControl,
158 LPCTSTR lpBinaryPathName,
159 LPCTSTR lpLoadOrderGroup,
160 LPDWORD lpdwTagId,
161 LPCTSTR lpDependencies,
162 LPCTSTR lpServiceStartName,
163 LPCTSTR lpPassword
164 );*/
165 Pointer CreateService(Pointer hSCManager, String lpServiceName, String lpDisplayName,
166 int dwDesiredAccess, int dwServiceType, int dwStartType, int dwErrorControl,
167 String lpBinaryPathName, String lpLoadOrderGroup, IntByReference lpdwTagId,
168 String lpDependencies, String lpServiceStartName, String lpPassword);
169
170 /*
171 BOOL WINAPI DeleteService(
172 SC_HANDLE hService
173 );*/
174 boolean DeleteService(Pointer hService);
175
176 /*
177 BOOL WINAPI ChangeServiceConfig2(
178 SC_HANDLE hService,
179 DWORD dwInfoLevel,
180 LPVOID lpInfo
181 );*/
182 boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel, ChangeServiceConfig2Info lpInfo);
183
184 /*
185 LONG WINAPI RegOpenKeyEx(
186 HKEY hKey,
187 LPCTSTR lpSubKey,
188 DWORD ulOptions,
189 REGSAM samDesired,
190 PHKEY phkResult
191 );*/
192 int RegOpenKeyEx(int hKey, String lpSubKey, int ulOptions, int samDesired, IntByReference phkResult);
193
194 /*
195 LONG WINAPI RegQueryValueEx(
196 HKEY hKey,
197 LPCTSTR lpValueName,
198 LPDWORD lpReserved,
199 LPDWORD lpType,
200 LPBYTE lpData,
201 LPDWORD lpcbData
202 );*/
203 int RegQueryValueEx(int hKey, String lpValueName, IntByReference lpReserved, IntByReference lpType, byte[] lpData, IntByReference lpcbData);
204
205 /*
206 LONG WINAPI RegCloseKey(
207 HKEY hKey
208 );*/
209 int RegCloseKey(int hKey);
210
211 /*
212 LONG WINAPI RegDeleteValue(
213 HKEY hKey,
214 LPCTSTR lpValueName
215 );*/
216 int RegDeleteValue(int hKey, String lpValueName);
217
218 /*
219 LONG WINAPI RegSetValueEx(
220 HKEY hKey,
221 LPCTSTR lpValueName,
222 DWORD Reserved,
223 DWORD dwType,
224 const BYTE* lpData,
225 DWORD cbData
226 );*/
227 int RegSetValueEx(int hKey, String lpValueName, int Reserved, int dwType, byte[] lpData, int cbData);
228
229 /*
230 LONG WINAPI RegCreateKeyEx(
231 HKEY hKey,
232 LPCTSTR lpSubKey,
233 DWORD Reserved,
234 LPTSTR lpClass,
235 DWORD dwOptions,
236 REGSAM samDesired,
237 LPSECURITY_ATTRIBUTES lpSecurityAttributes,
238 PHKEY phkResult,
239 LPDWORD lpdwDisposition
240 );*/
241 int RegCreateKeyEx(int hKey, String lpSubKey, int Reserved, String lpClass, int dwOptions,
242 int samDesired, WINBASE.SECURITY_ATTRIBUTES lpSecurityAttributes, IntByReference phkResult,
243 IntByReference lpdwDisposition);
244
245 /*
246 LONG WINAPI RegDeleteKey(
247 HKEY hKey,
248 LPCTSTR lpSubKey
249 );*/
250 int RegDeleteKey(int hKey, String name);
251
252 /*
253 LONG WINAPI RegEnumKeyEx(
254 HKEY hKey,
255 DWORD dwIndex,
256 LPTSTR lpName,
257 LPDWORD lpcName,
258 LPDWORD lpReserved,
259 LPTSTR lpClass,
260 LPDWORD lpcClass,
261 PFILETIME lpftLastWriteTime
262 );*/
263 int RegEnumKeyEx(int hKey, int dwIndex, char[] lpName, IntByReference lpcName, IntByReference reserved,
264 char[] lpClass, IntByReference lpcClass, WINBASE.FILETIME lpftLastWriteTime);
265
266 /*
267 LONG WINAPI RegEnumValue(
268 HKEY hKey,
269 DWORD dwIndex,
270 LPTSTR lpValueName,
271 LPDWORD lpcchValueName,
272 LPDWORD lpReserved,
273 LPDWORD lpType,
274 LPBYTE lpData,
275 LPDWORD lpcbData
276 );*/
277 int RegEnumValue(int hKey, int dwIndex, char[] lpValueName, IntByReference lpcchValueName, IntByReference reserved,
278 IntByReference lpType, byte[] lpData, IntByReference lpcbData);
279
280 interface SERVICE_MAIN_FUNCTION extends StdCallCallback {
281 /*
282 VOID WINAPI ServiceMain(
283 DWORD dwArgc,
284 LPTSTR* lpszArgv
285 );*/
286 void callback(int dwArgc, Pointer lpszArgv);
287 }
288
289 interface Handler extends StdCallCallback {
290 /*
291 VOID WINAPI Handler(
292 DWORD fdwControl
293 );*/
294 void callback(int fdwControl);
295 }
296
297 interface HandlerEx extends StdCallCallback {
298 /*
299 DWORD WINAPI HandlerEx(
300 DWORD dwControl,
301 DWORD dwEventType,
302 LPVOID lpEventData,
303 LPVOID lpContext
304 );*/
305 int callback(int dwControl, int dwEventType, Pointer lpEventData, Pointer lpContext);
306 }
307
308 /*
309 typedef struct _SERVICE_STATUS {
310 DWORD dwServiceType;
311 DWORD dwCurrentState;
312 DWORD dwControlsAccepted;
313 DWORD dwWin32ExitCode;
314 DWORD dwServiceSpecificExitCode;
315 DWORD dwCheckPoint;
316 DWORD dwWaitHint;
317 } SERVICE_STATUS,
318 *LPSERVICE_STATUS;*/
319 class SERVICE_STATUS extends Structure {
320 public int dwServiceType;
321 public int dwCurrentState;
322 public int dwControlsAccepted;
323 public int dwWin32ExitCode;
324 public int dwServiceSpecificExitCode;
325 public int dwCheckPoint;
326 public int dwWaitHint;
327 }
328
329 /*
330 typedef struct _SERVICE_TABLE_ENTRY {
331 LPTSTR lpServiceName;
332 LPSERVICE_MAIN_FUNCTION lpServiceProc;
333 } SERVICE_TABLE_ENTRY,
334 *LPSERVICE_TABLE_ENTRY;*/
335 class SERVICE_TABLE_ENTRY extends Structure {
336 public String lpServiceName;
337 public SERVICE_MAIN_FUNCTION lpServiceProc;
338 }
339
340 class ChangeServiceConfig2Info extends Structure {
341 }
342
343 /*
344 typedef struct _SERVICE_DESCRIPTION {
345 LPTSTR lpDescription;
346 } SERVICE_DESCRIPTION,
347 *LPSERVICE_DESCRIPTION;*/
348 class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info {
349 public String lpDescription;
350 }
351 }