Package com.sun.jna.examples.win32.WinNT

Examples of com.sun.jna.examples.win32.WinNT.HANDLE


        Kernel32 klib = Kernel32.INSTANCE;
        int mask = WinNT.FILE_SHARE_READ
            | WinNT.FILE_SHARE_WRITE | WinNT.FILE_SHARE_DELETE;
        int flags = WinNT.FILE_FLAG_BACKUP_SEMANTICS
            | WinNT.FILE_FLAG_OVERLAPPED;
        HANDLE handle = klib.CreateFile(file.getAbsolutePath(),
            WinNT.FILE_LIST_DIRECTORY,
            mask, null, WinNT.OPEN_EXISTING,
                flags, null);
        if (WinBase.INVALID_HANDLE_VALUE.equals(handle)) {
            throw new IOException("Unable to open " + file + " ("
                                  + klib.GetLastError() + ")");
        }
        int notifyMask = convertMask(eventMask);
        FileInfo finfo = new FileInfo(file, handle, notifyMask, recursive);
        fileMap.put(file, finfo);
        handleMap.put(handle, finfo);
        // Existing port is returned
        port = klib.CreateIoCompletionPort(handle, port, handle.getPointer(), 0);
        if (WinBase.INVALID_HANDLE_VALUE.equals(port)) {
            throw new IOException("Unable to create/use I/O Completion port "
                    + "for " + file + " ("
                    + klib.GetLastError() + ")");
        }
View Full Code Here


        File f = new File(fileName);
        if (!f.exists()) {
            throw new FileNotFoundException(fileName);
        }

        HANDLE hFile = null;
        try {
            hFile = Kernel32.INSTANCE.CreateFile(fileName, WinNT.GENERIC_READ,
                    WinNT.FILE_SHARE_READ, new WinBase.SECURITY_ATTRIBUTES(),
                    WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL,
                    new HANDLEByReference().getValue());
View Full Code Here

      assertTrue(Advapi32.INSTANCE.CloseEventLog(h));    
    }
    */
   
    public void testBackupEventLog() {
      HANDLE h = Advapi32.INSTANCE.OpenEventLog(null, "Application");
      assertNotNull(h);
      String backupFileName = Kernel32Util.getTempPath() + "\\JNADevEventLog.bak";     
      File f = new File(backupFileName);
      if (f.exists()) {
        f.delete();
      }
   
      assertTrue(Advapi32.INSTANCE.BackupEventLog(h, backupFileName));
      HANDLE hBackup = Advapi32.INSTANCE.OpenBackupEventLog(null, backupFileName);
      assertNotNull(hBackup);
     
      IntByReference n = new IntByReference();
      assertTrue(Advapi32.INSTANCE.GetNumberOfEventLogRecords(hBackup, n));
      assertTrue(n.getValue() >= 0);
View Full Code Here

      assertTrue(Advapi32.INSTANCE.CloseEventLog(h));
      assertTrue(Advapi32.INSTANCE.CloseEventLog(hBackup));
    }
   
    public void testReadEventLog() {
      HANDLE h = Advapi32.INSTANCE.OpenEventLog(null, "Application");
      IntByReference pnBytesRead = new IntByReference();
      IntByReference pnMinNumberOfBytesNeeded = new IntByReference();
      Memory buffer = new Memory(1);
      assertFalse(Advapi32.INSTANCE.ReadEventLog(h,
          WinNT.EVENTLOG_SEQUENTIAL_READ | WinNT.EVENTLOG_BACKWARDS_READ,
View Full Code Here

      assertTrue(pnMinNumberOfBytesNeeded.getValue() > 0);
      assertTrue(Advapi32.INSTANCE.CloseEventLog(h));
    }
   
    public void testReadEventLogEntries() {
      HANDLE h = Advapi32.INSTANCE.OpenEventLog(null, "Application");
      IntByReference pnBytesRead = new IntByReference();
      IntByReference pnMinNumberOfBytesNeeded = new IntByReference();
      Memory buffer = new Memory(1024 * 64);
      // shorten test, avoid iterating through all events
      int maxReads = 3;      
View Full Code Here

        assertTrue("Error closing event log",
                   Advapi32.INSTANCE.CloseEventLog(h));     
    }
   
    public void testGetOldestEventLogRecord() {
      HANDLE h = Advapi32.INSTANCE.OpenEventLog(null, "Application");
      IntByReference oldestRecord = new IntByReference();
      assertTrue(Advapi32.INSTANCE.GetOldestEventLogRecord(h, oldestRecord));
      assertTrue(oldestRecord.getValue() >= 0);
      assertTrue(Advapi32.INSTANCE.CloseEventLog(h));
    }
View Full Code Here

      assertEquals(W32Errors.ERROR_INVALID_HANDLE, Kernel32.INSTANCE.GetLastError());
    }
   
    public void testCreateProcessAsUser() {
      HANDLEByReference hToken = new HANDLEByReference();
      HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess();
      assertTrue(Advapi32.INSTANCE.OpenProcessToken(processHandle,
          WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, hToken));
     
      assertFalse(Advapi32.INSTANCE.CreateProcessAsUser(hToken.getValue(), null, "InvalidCmdLine.jna",
          null, null, false, 0, null, null, new WinBase.STARTUPINFO(),
View Full Code Here

    PHYSICAL_MONITOR[] physMons = new PHYSICAL_MONITOR[monitorCount];
    Dxva2.INSTANCE.GetPhysicalMonitorsFromHMONITOR(hMonitor, monitorCount, physMons);
   
    for (int i = 0; i < monitorCount; i++)
    {
      HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
      System.out.println("Monitor " + i + " - " + new String(physMons[i].szPhysicalMonitorDescription));
   
      enumeratePhysicalMonitor(hPhysicalMonitor);
    }
   
View Full Code Here

   */
  public static Account[] getCurrentUserGroups() {
    HANDLEByReference phToken = new HANDLEByReference();
    try {
      // open thread or process token
      HANDLE threadHandle = Kernel32.INSTANCE.GetCurrentThread();
      if (!Advapi32.INSTANCE.OpenThreadToken(threadHandle,
          TOKEN_DUPLICATE | TOKEN_QUERY, true, phToken)) {
        if (W32Errors.ERROR_NO_TOKEN != Kernel32.INSTANCE
            .GetLastError()) {
          throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
        }
        HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess();
        if (!Advapi32.INSTANCE.OpenProcessToken(processHandle,
            TOKEN_DUPLICATE | TOKEN_QUERY, phToken)) {
          throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
        }
      }
View Full Code Here

                int w = bounds.width;
                int h = bounds.height;
                int ww = win.getWidth();
                int wh = win.getHeight();
                HDC screenDC = user.GetDC(null);
                HANDLE oldBitmap = null;
                try {
                    if (memDC == null) {
                        memDC = gdi.CreateCompatibleDC(screenDC);
                    }
                    if (hBitmap == null || !win.getSize().equals(bitmapSize)) {
View Full Code Here

TOP

Related Classes of com.sun.jna.examples.win32.WinNT.HANDLE

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.