---
title: llarp/win32/handle.hpp

---

# llarp/win32/handle.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |
| **[llarp::win32](Namespaces/namespacellarp_1_1win32.md)**  |




## Source code

```cpp
#pragma once

#include "exception.hpp"

namespace llarp::win32
{
  inline void
  ensure_handle_is_valid(HANDLE h)
  {
    BY_HANDLE_FILE_INFORMATION info{};
    if (GetFileInformationByHandle(h, &info))
      return;
    if (auto err = GetLastError())
    {
      SetLastError(0);
      throw llarp::win32::error{err, "handle validity check failed"};
    }
  }
}  // namespace llarp::win32
```


-------------------------------

Updated on 2023-02-01 at 20:39:33 +0000
