# Full Win32API headers and bindings for Julia (WIP)

**URL:** https://discourse.julialang.org/t/full-win32api-headers-and-bindings-for-julia-wip/69657
**Category:** Package Announcements
**Created:** [October 13, 2021, 4:43am UTC](https://discourse.julialang.org/t/full-win32api-headers-and-bindings-for-julia-wip/69657 "2021-10-13T04:43:17Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Chris\_Green](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chris_green/32/32265_2.png) [@Chris\_Green](https://discourse.julialang.org/u/Chris_Green)
#### Post date: [October 13, 2021, 4:43am UTC](https://discourse.julialang.org/t/full-win32api-headers-and-bindings-for-julia-wip/69657/1 "2021-10-13T04:43:17Z")

</div>

Hi. I have just started programming in Julia.

I needed access to some WIN32 APIs so that I could deal with some threading issues in the Julia runtime. I got tired of making manual definitions, and banged out a really bad .h translator. it is no way a full C parser - it’s just trying to work on windows.h. Though I could certainly pull in some other APIs this way.

Its just WIP, though I did try some calls and they work. There are definitely errors in here, and you’ll get a couple of multiple def warnings because I am not parsing #if correctly. That’s my next fix.

Since I am new to Julia, I am especially looking for feedback on how I am exposing the various win32 structs and definitions. Suggestions welcome on how to make these bindings work best for the language.

Here is the link:  
[https://github.com/aachrisg/JuliaWin32API](https://github.com/aachrisg/JuliaWin32API)

PS: I know it could definitely indent better, etc. Every line of that file was generated by my script, so I figure I can make its output a little prettier when its more complete. I’ll put them in a module when done.

---

<div class="post-metadata">

### Author: ![woclass](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/woclass/32/212699_2.png) [@woclass](https://discourse.julialang.org/u/woclass)
#### Post date: [October 13, 2021, 5:59am UTC](https://discourse.julialang.org/t/full-win32api-headers-and-bindings-for-julia-wip/69657/2 "2021-10-13T05:59:54Z")

</div>

Maybe we shouldn’t parse the headers manually…

> Historically, this has required manually [redefining the APIs](http://pinvoke.net/) to make them accessible, which is fragile and error-prone. Community projects like [GitHub - dotnet/pinvoke: A library containing all P/Invoke code so you don't have to import it every time. Maintained and updated to support the latest Windows OS.](https://github.com/dotnet/pinvoke) (.NET) and [GitHub - retep998/winapi-rs: Rust bindings to Windows API](https://github.com/retep998/winapi-rs) (Rust) have taken on the burden of providing strongly-typed and validated API signatures for their frameworks, but the projects are manually maintained, which is hard to sustain and makes it challenging to provide thorough API coverage.
> 
> This project aims to provide metadata for Win32 APIs such that idiomatic [projections](https://github.com/microsoft/win32metadata/blob/master/docs/projections.md) and projects like the ones above can be generated for all languages and frameworks in a more automated way and with more complete API coverage.

> **[GitHub - microsoft/win32metadata: Tooling to generate metadata for Win32 APIs...](https://github.com/microsoft/win32metadata)**
>
> Tooling to generate metadata for Win32 APIs in the Windows SDK. - GitHub - microsoft/win32metadata: Tooling to generate metadata for Win32 APIs in the Windows SDK.

Some community win32 API binding generators:

- Zig: [GitHub - marlersoft/zigwin32gen: Generates Complete Zig bindings for Win32. See https://github.com/marlersoft/zigwin32 for the bindings themselves.](https://github.com/marlersoft/zigwin32gen)
- D: [GitHub - rumbu13/windows-d](https://github.com/rumbu13/windows-d)
- Dart: [https://github.com/timsneath/win32/blob/main/tool/manual\_gen/README.md](https://github.com/timsneath/win32/blob/main/tool/manual_gen/README.md)

* * *

And Clang.jl can gen some bindings from C header.  
[https://juliainterop.github.io/Clang.jl/stable/#C-bindings-generator](https://juliainterop.github.io/Clang.jl/stable/#C-bindings-generator)

---

<div class="post-metadata">

### Author: ![Chris\_Green](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chris_green/32/32265_2.png) [@Chris\_Green](https://discourse.julialang.org/u/Chris_Green)
#### Post date: [October 13, 2021, 8:11am UTC](https://discourse.julialang.org/t/full-win32api-headers-and-bindings-for-julia-wip/69657/3 "2021-10-13T08:11:26Z")

</div>

Thanks for the links. I could probably use that metadata in conjunction with my dumb parser. I only spent a couple hours on the parser and I might want to apply it to my own c++ code, so no waste.

One thing I am doing to validate them is outputting c code that can be compiled against windows.h that checks that all the struct sizes match between c and julia.
