Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   NSIS Function to get main display refresh rate? (http://forums.winamp.com/showthread.php?t=454766)

enzeinzen 17th June 2019 21:13

NSIS Function to get main display refresh rate?
 
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.

Anders 17th June 2019 21:31

You did say main display which I interpret as the primary monitor.

Quote:

!define /IfNDef VREFRESH 116
System::Call USER32::GetDC(p0)p.r1
System::Call GDI32::GetDeviceCaps(pr1,i${VREFRESH})i.r0
System::Call USER32::ReleaseDC(p0,pr1)
DetailPrint $0
but
Quote:

For display devices: the current vertical refresh rate of the device, in cycles per second (Hz).
A vertical refresh rate value of 0 or 1 represents the display hardware's default refresh rate.
Not sure if recent hardware can report 0 or 1 or maybe it was just Win95/98.

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.

enzeinzen 17th June 2019 21:54

It does seem to work but it only returns 0.

Anders 18th June 2019 13:53

Quote:

!define /IfNDef CCHDEVICENAME 32
!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}
for
Quote:

the current display device on the computer on which the calling thread is running
whatever that means.

MaGoth 2nd September 2019 10:18

Hi, enzeinzen
If still relevant, is this solution suitable for you?

https://cdn.discordapp.com/attachmen...23/unknown.png

MfG MaGoth, :)

enzeinzen 11th September 2019 17:21

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.

enzeinzen 11th September 2019 17:50

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

Anders 12th September 2019 10:48

What is the problem with the last code I posted?


All times are GMT. The time now is 17:20.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.