Hi' i'm trying to include a function in my script to detect the refresh rate of the main display. However, I do not know how to incorporate the functions into NSIS code.
I already managed to find a way to get the resolution using the following code:
System::Call user32::GetSystemMetrics(i0)i.r0
System::Call user32::GetSystemMetrics(i1)i.r1
However, in order to obtain the refresh rate, one must use EnumDisplayDevices to get the right display and then pass that to EnumDisplaySettings. I do not know how to do that.
Any help would be much appreciated. I am trying to build a portable application using the portableapps.com framework that uses NSIS language.
Thank you and sorry for being a n00b.
NSIS Function to get main display refresh rate?
8 posts
You did say main display which I interpret as the primary monitor.
https://nsis.sourceforge.io/NSISMultiMon_plug-in can give you some information about the different monitors. https://nsis.sourceforge.io/ChangeRes_plug-in can change it but I don't think it can read it.
!define /IfNDef VREFRESH 116but
System::Call USER32::GetDC(p0)p.r1
System::Call GDI32::GetDeviceCaps(pr1,i${VREFRESH})i.r0
System::Call USER32::ReleaseDC(p0,pr1)
DetailPrint $0
For display devices: the current vertical refresh rate of the device, in cycles per second (Hz).Not sure if recent hardware can report 0 or 1 or maybe it was just Win95/98.
A vertical refresh rate value of 0 or 1 represents the display hardware's default refresh rate.
https://nsis.sourceforge.io/NSISMultiMon_plug-in can give you some information about the different monitors. https://nsis.sourceforge.io/ChangeRes_plug-in can change it but I don't think it can read it.
It does seem to work but it only returns 0.
!define /IfNDef CCHDEVICENAME 32for
!define /IfNDef CCHFORMNAME 32
!define /IfNDef ENUM_CURRENT_SETTINGS -1
!define /IfNDef DM_DISPLAYFREQUENCY 0x00400000
!include LogicLib.nsh
System::Call '*(&i${CCHDEVICENAME},i,&l2,&i2,i0, i,i,i,i, i,i,&i2,&i${CCHFORMNAME},&i2,i,i,i,i,i)p.r1'
System::Call 'USER32::EnumDisplaySettingsA(p0, i${ENUM_CURRENT_SETTINGS}, pr1)i.r0'
System::Call '*$1(&i${CCHDEVICENAME},i,&l2,&i2,i, i,i,i,i, i,i,&i2,&i${CCHFORMNAME},&i2,i,i,i,i,i.r2)'
System::Free $1
${If} $0 <> 0
DetailPrint $2
${EndIf}
the current display device on the computer on which the calling thread is runningwhatever that means.
Hi, enzeinzen
If still relevant, is this solution suitable for you?

MfG MaGoth, 🙂
If still relevant, is this solution suitable for you?

MfG MaGoth, 🙂
No, sadly I didn't manage to find a way to make this work. What I'm trying to do is incorporate this into a PortableApps.com launcher. Getting a function that is so complex to work within the PA.com framework is, however above my level of competence.
For example, this is how obtaining the resolution for further use is done:
${SegmentInit}
System::Call user32::GetSystemMetrics(i0)i.r0
System::Call user32::GetSystemMetrics(i1)i.r1
${SetEnvironmentVariable} ScreenWidth $0
${SetEnvironmentVariable} ScreenHeight $1
${SegmentInit}
System::Call user32::GetSystemMetrics(i0)i.r0
System::Call user32::GetSystemMetrics(i1)i.r1
${SetEnvironmentVariable} ScreenWidth $0
${SetEnvironmentVariable} ScreenHeight $1
What is the problem with the last code I posted?