Disabling Desktop Composition using Lua Scripting

梦想的初衷 提交于 2019-12-13 05:37:53

问题


Im using Set-Up Factory from IndigoRose for building my installers. Set-up factory uses lua language in the scripting section of the installers. Now, for my application once the installing is done, I would like to run a script which disables desktop decomposition if the operating system is windows 7. Is there a way I can access dwmapi.lib in lua for doing it. Is there a system library function to access desktop window manager?

I have done some googling and found out the following code for vbscript..

Private Const DWM_EC_DISABLECOMPOSITION As Long = 0
Private Const DWM_EC_ENABLECOMPOSITION As Long = 1

Private Declare Function DwmEnableComposition Lib "dwmapi" (uCompositionAction As Long) As Long

Private Function SUCCEEDED(hr As Long) As Boolean
    SUCCEEDED = (hr >= 0)
End Function
Private Function FAILED(hr As Long) As Boolean
    FAILED = (hr < 0)
End Function

Private Sub Form_Load()
    If SUCCEEDED(DwmEnableComposition(DWM_EC_DISABLECOMPOSITION)) Then
        MsgBox "Vista Aero est Desactive"
    Else
        MsgBox "Vista Aero n'a pas pu etre Desactive"
    End If

End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    MsgBox Cancel
    MsgBox UnloadMode
    If SUCCEEDED(DwmEnableComposition(DWM_EC_ENABLECOMPOSITION)) Then
        MsgBox "Vista Aero est Active"
    Else
        MsgBox "Vista Aero n'a pas pu etre active"
    End If

End Sub 

How can I do this in LUA??


回答1:


Since you don't have header files and you directly want to access functions from a DLL (dwmapi.dll) from Lua, you would have to try on of the "foreign function interface" libraries out there. Look at the section "C Foreign Function Interfaces" on the Lua Wiki for links to Alien (wraps libffi), LuaJIT FFI (if you want to use LuaJIT), and C/Invoke Lua.



来源:https://stackoverflow.com/questions/22032642/disabling-desktop-composition-using-lua-scripting

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!