Refine search
public static void deleteFile(String filename) { if (!Kernel32.INSTANCE.DeleteFile(filename)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } }
/** * Closes the previously opened Service Manager. */ @Override public void close() { if (_handle != null) { if (! Advapi32.INSTANCE.CloseServiceHandle(_handle)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } _handle = null; } }
public static void deleteFile(String filename) { if (! Kernel32.INSTANCE.DeleteFile(filename)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } }
/** * Impersonate a logged on user. * * @param windowsIdentity * Windows identity obtained via LogonUser. */ public WindowsIdentityImpersonationContextImpl(final HANDLE windowsIdentity) { if (!Advapi32.INSTANCE.ImpersonateLoggedOnUser(windowsIdentity)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } }
/** * Invokes {@link Kernel32#LocalFree(Pointer)} and checks if it succeeded. * * @param ptr The {@link Pointer} to the memory to be released - ignored if NULL * @throws Win32Exception if non-{@code ERROR_SUCCESS} code reported */ public static void freeLocalMemory(Pointer ptr) { Pointer res = Kernel32.INSTANCE.LocalFree(ptr); if (res != null) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } }
/** * Invokes {@link Kernel32#GlobalFree(Pointer)} and checks if it succeeded. * * @param ptr The {@link Pointer} to the memory to be released - ignored if NULL * @throws Win32Exception if non-{@code ERROR_SUCCESS} code reported */ public static void freeGlobalMemory(Pointer ptr) { Pointer res = Kernel32.INSTANCE.GlobalFree(ptr); if (res != null) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } }
/** * Close service. */ @Override public void close() { if (_handle != null) { if (! Advapi32.INSTANCE.CloseServiceHandle(_handle)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } _handle = null; } }
public static final int registerWindowMessage(final String lpString) { final int messageId = User32.INSTANCE.RegisterWindowMessage(lpString); if (messageId == 0) throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); return messageId; }
public EventLogIterator(String serverName, String sourceName, int flags) { _flags = flags; _h = Advapi32.INSTANCE.OpenEventLog(serverName, sourceName); if (_h == null) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } }
/** * Closes the previously opened Service Manager. */ public void close() { if (_handle != null) { if (! Advapi32.INSTANCE.CloseServiceHandle(_handle)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } _handle = null; } }
/** * Impersonate a logged on user. * * @param windowsIdentity * Windows identity obtained via LogonUser. */ public WindowsIdentityImpersonationContextImpl(final HANDLE windowsIdentity) { if (!Advapi32.INSTANCE.ImpersonateLoggedOnUser(windowsIdentity)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } }
/** * Call close() in the case when the caller needs to abandon the * iterator before the iteration completes. */ public void close() { _done = true; if (_h != null) { if (!Advapi32.INSTANCE.CloseEventLog(_h)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } _h = null; } }
public static final int registerWindowMessage(final String lpString) { final int messageId = User32.INSTANCE.RegisterWindowMessage(lpString); if (messageId == 0) throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); return messageId; }
public static final HWND createWindowEx(final int exStyle, final String className, final String windowName, final int style, final int x, final int y, final int width, final int height, final HWND parent, final HMENU menu, final HINSTANCE instance, final LPVOID param) { final HWND hWnd = User32.INSTANCE .CreateWindowEx(exStyle, className, windowName, style, x, y, width, height, parent, menu, instance, param); if (hWnd == null) throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); return hWnd; }
/** * Encrypts a file or directory. * * @param file * The file or directory to encrypt. */ public static void encryptFile(File file) { String lpFileName = file.getAbsolutePath(); if (!Advapi32.INSTANCE.EncryptFile(lpFileName)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } }
public static final void destroyWindow(final HWND hWnd) { if (!User32.INSTANCE.DestroyWindow(hWnd)) throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); }
/** * Retrieves file system attributes for a specified file or directory. * * @param fileName * The name of the file or directory. * @return The attributes of the specified file or directory. */ public static int getFileAttributes(String fileName) { int fileAttributes = Kernel32.INSTANCE.GetFileAttributes(fileName); if (fileAttributes == WinBase.INVALID_FILE_ATTRIBUTES) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } return fileAttributes; }
public static final void destroyWindow(final HWND hWnd) { if (!User32.INSTANCE.DestroyWindow(hWnd)) throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } }
public static final void writePrivateProfileString(final String appName, final String keyName, final String string, final String fileName) { if (!Kernel32.INSTANCE.WritePrivateProfileString(appName, keyName, string, fileName)) throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } }
public static final void writePrivateProfileString(final String appName, final String keyName, final String string, final String fileName) { if (!Kernel32.INSTANCE.WritePrivateProfileString(appName, keyName, string, fileName)) throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); }