[Implemented] SetClassLongPtr and SetWindowLongPtr api call

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

[Implemented] SetClassLongPtr and SetWindowLongPtr api call

Post by Rescator »

This function supersedes the SetClassLong function. To write code that is compatible with both 32-bit and 64-bit Microsoft Windows, use SetClassLongPtr.
Minimum DLL Version user32.dll
Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 95, Windows NT 3.1
Unicode Implemented as ANSI and Unicode versions.


It is identical in use and requirements to SetClassLong,
so Fred could you add this for next PB update of api module/lib?
I know a lot of interface tricks and stuff uses SetClassLong,
but they really should use SetClassLongPtr instead.
Same with SetWindowLong.... SetWindowLongPtr should be used instead!

Note: Info taken straight from MicroSofts XPSP2-SDK!

It's possible that there are even more cases like this.
Last edited by Rescator on Thu Sep 29, 2011 12:56 pm, edited 1 time in total.
Doobrey
Enthusiast
Enthusiast
Posts: 218
Joined: Sat Apr 26, 2003 4:47 am
Location: Dullsville..population: me
Contact:

Re: SetClassLongPtr and SetWindowLongPtr api call is missing

Post by Doobrey »

Rescator wrote:
It is identical in use and requirements to SetClassLong
If it does exactly the same thing, why does MS see fit to change its name ?
This may sound stupid and bleeding obvious, but do you get the feeling that MS don`t want old software running on their latest OS ?
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

what's new? they took out part of the thunking functionality in winxp, so 16 bit programs had no longer access to certain 32 bit functions, however they did not take out all functionality, just those that made 16 bit apps look like 32 bit apps (file selectors etc.)

under win2k there was no issue, then suddenly under winxp there is... now there's 64 bits coming up with wow, and 16 will no longer be supported, and 32 bit is, well, waiting for the axe to fall
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

I assume that SetClassLong would be under the 32bit emulation layer or 32bit mode,
while SetClassLongPtr is the "native" call.
i.e. on 32bit OS SetClassLongPtr is a 32bit call, while on a 64bit OS it's a 64bit call.

For all I know SetClassLongPtr and SetClassLong are the same on 32bit XP,
but on 64bit XP etc they probably aren't.
So the SetClassLong and SetClassLongPtr makes sense,
as older apps would use SetClassLong and most likely not 64bit comptatible,
while SetClassLongPtr are either 64bit or 32bit (but 64bit compatible).

Altough I do suspect that SetClassLong on a 64bit OS is the native 64bit call,
and will only work if the app is a 64bit app.

Thing is, when I stumbled over this and tried to use SetClassLongPtr and it wasn't in PB's list it kinda set me back for a sec,
as my first thought was. "Damn! So this program won't run on a 64bit windows then".

What surprises me tough is that SetClassLongPtr seems to have existed since Win95,
does this mean that SetClassLong is a remnant from old Win 3.x ?
In which case it kinda makes sense (from MS standpoint)
they'd effectivly prevent 16bit apps from running at all on a 64bit OS.
Post Reply