<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>potisan</author_name>
  <author_url>https://blog.hatena.ne.jp/potisan/</author_url>
  <blog_title>potisanのプログラミングメモ</blog_title>
  <blog_url>https://potisan-programming-memo.hatenablog.jp/</blog_url>
  <categories>
    <anon>Python 3</anon>
  </categories>
  <description>ctypesモジュールは関数のrestypeにctypes.HRESULTを指定すると戻り値がエラーの場合に自動でraiseするようです。エラーの発生時は手動で握りつぶそうとしていたのですが、可読性のためにctypes.c_intをctypes.HRESULTに変えたらOSErrorが発生するようになりました。便利ですが気づきにくい仕様です。 追記（2024/8/10）：公式ドキュメントではctypes.OleDLLの説明にそれらしい記載があります。記載中のHRESULTの扱いはctypes.OleDLL以外でも適用されるようです。</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fpotisan-programming-memo.hatenablog.jp%2Fentry%2F2022%2F09%2F03%2F185215&quot; title=&quot;Python 3 ctypesは関数のrestypeにctypes.HRESULTを指定すると自動でエラーを発生する - potisanのプログラミングメモ&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2022-09-03 18:52:15</published>
  <title>Python 3 ctypesは関数のrestypeにctypes.HRESULTを指定すると自動でエラーを発生する</title>
  <type>rich</type>
  <url>https://potisan-programming-memo.hatenablog.jp/entry/2022/09/03/185215</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
