问题
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