Skip to content

Instantly share code, notes, and snippets.

@jglathe
Created April 16, 2023 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jglathe/d35ce5f00b95237ffe512296bc3f8681 to your computer and use it in GitHub Desktop.
Save jglathe/d35ce5f00b95237ffe512296bc3f8681 to your computer and use it in GitHub Desktop.
innosetup import external library for specific call
[Files]
;for the install package: VersionInfo.dll
Source: "VersionInfo.dll"; Flags: dontcopy;
[Code]
function GetWindowsBuildNumber: Integer;
external '_GetWindowsBuildNumber@0@files:VersionInfo.dll stdcall delayload';
//in a function
BuildNumber := GetWindowsBuildNumber();
@jglathe
Copy link
Author

jglathe commented Apr 16, 2023

That was quite a session with ChatGPT and StackOverflow to hack this out. For the real name in the dll you need DependencyWalker. The dll will only be loaded at installation for something you can't do in InnoSetup. It's a good idea to compile the dll for x86. Turns out you can do this directly (getting the Build Number), but maybe it's useful for a case where you can't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment