Understanding the correct syntax for importing functions with v7

56 views
Skip to first unread message

Andrew Truckle

unread,
Mar 17, 2026, 11:11:50 AMMar 17
to innosetup
I have this import:

function SetWindowLongPtr(
  hWnd: HWND;
  nIndex: Integer;
  dwNewLong: NativeInt): NativeInt;
  external 'SetWindo...@user32.dll stdcall';

According to the official docus:

LONG_PTR SetWindowLongPtrW(
  [in] HWND     hWnd,
  [in] int      nIndex,
  [in] LONG_PTR dwNewLong
);

This compiles fine for 64 bit installers but fails to work properly for 32 bit installers:

[15:01:16.605]   Function and DLL name: SetWindo...@user32.dll
[15:01:16.607]   Importing the DLL function. Dest DLL name: user32.dll
[15:01:16.611]   Failed to import the DLL function (127).

I am sorry if I have overlooked an explanation. Thank you.

Andrew Truckle

unread,
Mar 17, 2026, 11:12:44 AMMar 17
to innosetup
Note that the system obscured the code as it though it was an email address.

SetWindowLongPtrW @ user32.dll

Martijn Laan

unread,
Mar 17, 2026, 12:52:24 PMMar 17
to innosetup
Hi,

SetWindowLongPtrW doesn't exist in 32-bit Windows. It only has SetWindowLongW.

Greetings,
Martijn

Op 17-3-2026 om 16:11 schreef Andrew Truckle:
--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/innosetup/62318771-4393-4c9d-a754-9d7b7ec559dfn%40googlegroups.com.

Andrew Truckle

unread,
Mar 17, 2026, 1:00:11 PMMar 17
to inno...@googlegroups.com
Ok so why does the Inno 6 installer work without any errors? Why has it become a problem now? But thanks and I will try as you suggested 

You received this message because you are subscribed to a topic in the Google Groups "innosetup" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/innosetup/iBtfraSnvSw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to innosetup+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/innosetup/177376633933.8.12549669294144274195.1234884096%40innosetup.nl.

Andrew Truckle

unread,
Mar 17, 2026, 1:03:35 PMMar 17
to innosetup
According to:


It states:

---
Note  This function has been superseded by the SetWindowLongPtr function. To write code that is compatible with both 32-bit and 64-bit versions of Windows, use the SetWindowLongPtr function.
---

So I am confused now.

Andrew Truckle

unread,
Mar 17, 2026, 3:19:44 PMMar 17
to innosetup
This works:

#ifdef WIN64

function SetWindowLongPtr(
  hWnd: HWND;
  nIndex: Integer;
  dwNewLong: NativeInt): NativeInt;
  external 'SetWindowLongPtrW @ user32.dll stdcall';
#else

function SetWindowLongPtr(
  hWnd: HWND;
  nIndex: Integer;
  dwNewLong: NativeInt): NativeInt;
  external 'SetWindowLongW @ user32.dll stdcall';
#endif


Martijn Laan

unread,
Mar 17, 2026, 5:38:57 PMMar 17
to innosetup
Hi,

Op 17-3-2026 om 17:59 schreef Andrew Truckle:
Ok so why does the Inno 6 installer work without any errors?

It doesn't. The import you posted doesn't work in Inno Setup 6 or any other version because there simply is no SetWindowLongPtrW function in 32-bit user32.dll. Also Inno Setup 6 doesn't compile the NativeInt type you used.


Note  This function has been superseded by the SetWindowLongPtr function. To write code that is compatible with both 32-bit and 64-bit versions of Windows, use the SetWindowLongPtr function

SetWindowLongPtr is a macro/alias which your compiler translates to the actual function in user32.dll, which is not named that.

Greetings,
Martijn

Andrew Truckle

unread,
Mar 17, 2026, 5:42:44 PMMar 17
to inno...@googlegroups.com
Yep. All understood now. 

Thank you. 

--
You received this message because you are subscribed to a topic in the Google Groups "innosetup" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/innosetup/iBtfraSnvSw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to innosetup+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages